Turning down a web server from a running container via bash

I have the following docker-compose.yml to start a webserver with PHP.

version: "2.0"


    image: nginx
      - "8000:80"
      - ./web:/web
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf

    image: php:${PHP_VERSION}-fpm
      - ./web:/web

After running docker-compose up, I can access my website perfectly at http://localhost:8000. But if I then access the nginx container, with:

$ docker-compose run nginx bash

and within the container I run:

$ service nginx stop

I still can see the website http://localhost:8000 being displayed in the browser.

How can it be that after stopping the server in the container, the website is still being delivered?

1 answer

  • answered 2018-04-14 15:53 psrcek

    The docker-compose run command starts a new container, you're stopping nginx in that new container, what you want is docker attach nginx

    The documentation is located here.