Why php development server hangs with docker compose?

I have the following docker-compose.yml configuration file:

  image: php:7.1
  command: php -S localhost:4000 /app/index.php
    - .:/app
    - 3000:4000

When I run docker-compose up it downloads the base image but then it hangs here:

  • Which capabilities can I drop in a Docker Nginx container?
  • Where to keep Dockerfile's in a project?
  • docker-machine without TLS verification
  • How to create docker image for postgis that will enable extension at build time or before container fully running?
  • How to send STDIN to docker process
  • How to scp a folder from windows to boot2docker?
  • Recreating silextwig_silex-twig_1
    Attaching to silextwig_silex-twig_1

    What am I doing wrong? There is nothing available on port 3000.
    I know there are setups with php-fpm + nginx but that seemed complicated for only development.

  • Pushing private repository to Docker Hub fails: HTTP code 504 while uploading metadata
  • How to publish ports in docker files
  • Dockerizing java app
  • Mongodb replicaset creation with authentication through docker script
  • uwsgi running in Docker can't find initializtion file
  • How I can run docker containers on the remote host?
  • One Solution collect form web for “Why php development server hangs with docker compose?”

    That is normal. It is attaching to the stdout of the container (for which there is no stdout being logged). At this point, the container is running.

    If you want to run in the background you would run with docker-compose up -d instead of just docker-compose up.

    The actual HTTP request to port 3000 won’t work because PHP is listening only on localhost. You need to modify your command to be php -S /app/index.php so that it is listening on all IP addresses and can accept connections through the Docker NAT.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.