Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)

Now that links are deprecated in docker-compose.yml (and were able to use the new networking feature to communicate between containers), we've lost a way to explicitly define dependencies between containers. How can we, now, tell our mysql container to come up first, before our API-server container starts up (which connects to mysql via the dns entry myapp_mysql_1 in docker-compose.yml?

1 Answer

0 votes
by (50.2k points)
edited by

Let’s assume that we have an nginx container depends on php container you can use volume_from as of now 

nginx:

  image: nginx

  ports:

    - "42080:80"

  volumes:

    - ./config/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro

  volumes_from:

    - php

 

php:

  build: config/docker/php

  ports:

    - "42022:22"

  volumes:

    - .:/var/www/html

  env_file: config/docker/php/.env.development

By this approach the volumes of php are exposed to nginx which is not a desired one but until depends_on feature is introduced.

There is a proposal to introduce "depends_on" in the new networking feature introduced by Docker.

The feature depends_on could be used to order the container start-up.

For more information please go through the following tutorial to get more info about docker:

Related questions

+1 vote
1 answer
0 votes
1 answer
asked May 31, 2019 in DevOps and Agile by Alex (1.4k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...