Docker Community Forums

Share and learn in the Docker community.

Docker Compose web server container is closed after UP

Good evening everyone,

I’m currently setting up an Apache2 & PHP web server. I now have the following problem: I wrote a Dockerfile and a docker-compose.yml.

After I got the command
sudo docker-compose up -d
If you enter the services are started, I also get the message “done” but they shut down directly under
sudo docker ps
no active containers can be found *

I also cannot reach the website via http: // IP ADDRESS …

Dockerfile
FROM debian
RUN apt update
RUN apt install apache2

docker-compose.yml
version: "3.8"
services:
  webserver:
    image: httpd: latest
    build:.
    ports:
      - "80:80"
      - "443: 443"
    volumes:
    - / var / www / html :.
  php:
    image: php: latest
    build:.
    volumes:
    - / var / www / html :.

Maybe someone can help me, thank you!

  • It can also be that I simply use it wrongly, I only tried to deal with docker today

You can use these docker-compose parameters to achieve that:

–abort-on-container-exit Stops all containers if any container was stopped.

–exit-code-from Return the exit code of the selected service container.

For example, having this docker-compose.yml:

version: ‘2.3’

services:
elasticsearch:

service-api:

service-test:

depends_on:
- elasticsearch
- service-api
The following command ensures that elasticsearch and service-api go down after service-test is finished, and returns the exit code from the service-test container:

docker-compose -f docker-compose.yml up
–abort-on-container-exit
–exit-code-from service-test