F
F
Farhod Daniyarov2021-07-13 08:44:53
Docker
Farhod Daniyarov, 2021-07-13 08:44:53

How to point a dependency to another container in docker-compose?

Hello.

Hence the question is this. Example.
I have docker-compose with a database. I run it through one docker-compose file.
There is a second docker-compose file, where I must specify the dependency on this container with the base, and so that the second application can access it.
Please give an example. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Shakhunov, 2021-07-20
@inf

Common practice #1 is one docker-compose.yml and depends_on in the service config
Common practice #2 is many docker-compose.yml where services are federated via an external network (network: external). At the same time, the restart:always configuration is set for the service of the main application, so that it restarts until it sees the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question