Running docker-compose up -d does not start the web container. But if you run docker-compose up -d again, it will be executed. That is, it does not run not the first time, what could be the problem? (screenshots and docker-compose.yml file below)

enter image description here

version: '3' services: web: image: nginx ports: - "8000:80" volumes: - ./:/var/www/html - ./site.conf:/etc/nginx/conf.d/default.conf php: build: . volumes: - ./:/var/www/html links: - postgres - redis redis: image: redis ports: - "6379:6379" postgres: image: postgres ports: - "5432:5432" 
  • one
    Look in the logs, there about the problem should be written. - D-side

2 answers 2

Your container most likely does not "not start", but "starts and immediately drops."

I will assume that your application at startup checks the availability of any of the related services, and, failing to find it (it has not yet managed to start), falls. By the second launch service has already been raised, so everything is going well.

    In version 3 of the format it is not recommended to use links .

    Try using depends_on ( depends_on manual).

    This link describes how to use the startup order in Compose.