mg-dp
mg-dp

Reputation: 98

Problem when trying to start services with my docker-compose file, one service randomly starts before another

so I have this problem, I have 3 services and for some reason with docker-compose up, the service which acts as a reverse proxy - webserver (namely nginx) will exit with exit code 1, I'm not experienced on it or in stackoverflow (so please if I miss something tell me to add it) and my file goes like this:

version: '3'

services:
  back:
    image: remote_image/image_name1:latest
    volumes:
      - /var/www/image_name1

  webserver:
    image: remote_image/image_name2:latest
    volumes:
      - /var/www/image_name2
    ports:
      - "8080:8080"

  front:
    image: remote_image/image_name3:latest
    volumes:
      - /var/www/image_name3

Am I missing something here?

Upvotes: 2

Views: 39

Answers (1)

sab
sab

Reputation: 1537

well without further info the only thing I could suggest is to add a depends_on in there (as follows if it depends on back and front, or only one of them depending on your needs) so you control the way the services start with your docker-compose up, beware to control dependencies of services to avoid problems:

  webserver:
    image: remote_image/image_name2:latest
    depends_on:
      - back
      - front
    volumes:
      - /var/www/image_name2
    ports:
      - "8080:8080"

Edit: as jonrsharpe mentions, dependency matters a lot, are they configured in your nginx config file? If yes, then only dependencies are missing.

Upvotes: 3

Related Questions