Skip to content

Instantly share code, notes, and snippets.

@yujiod
Created November 19, 2015 14:03
Show Gist options
  • Save yujiod/31af35417bffb80a08df to your computer and use it in GitHub Desktop.
Save yujiod/31af35417bffb80a08df to your computer and use it in GitHub Desktop.
Dockerfile example of php built-in server.
# Usage:
# docker build -t docker-php-example .
# docker run -d -p 8080:80 docker-php-example
# open http://192.168.99.100:8080/
FROM php
RUN echo "<?php echo 'Hello World';" > /tmp/index.php
CMD ["php", "-S", "0.0.0.0:80", "-t", "/tmp"]
Copy link

ghost commented Sep 9, 2016

Hey buddy,

I was actually trying to do something very similar.
I can easily startup a server from within the container, but when try to do something similar to the above, I have an unexpected error and I was wondering if you would have any clues to this.

Dockerfile

FROM php
ENV APP_DIR /var/www/app
ENV APPLICATION_ENV development
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR
EXPOSE 80
VOLUME $APP_DIR
CMD ["php", "-S", "0.0.0.0:80", "-t", "./public", "./public/index.php"]

And when I do docker run -d -v "$PWD":/var/www/app -p 80:80 phpd the CMD doesn't seem to work as expected:
docker ps -a prints the following (notice that the command cuts at -t):

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS               NAMES
9a6b7dd84805        phpd                "php -S 0.0.0.0:80 -t"   2 seconds ago       Exited (1) 2 seconds ago                       phpd

Any clues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment