Answer the question
In order to leave comments, you need to log in
How to ensure the interaction of docker containers?
Hello comrades!
I deleted the previous question completely, because ... An incorrectly asked question leads to an unnecessary answer.
Now the question is: how to ensure the interaction of containers?
There is a container with an application. In my case nextcloud, there is a container with a database, and a container with a database. These are different containers that live in different directories (on the host) and run via docker-compose.
Through docker-exec, I climbed into the nextcloud container, installed ping in it and tried to somehow dope to the container with the database. In vain!
I will give a docker-compose container with MySQL
version: '3'
services:
mysql_server:
container_name: mysql_server
image: mysql:latest
ports:
- 3306:3306
environment:
- MYSQL_ROOT_PASSWORD=password
volumes:
- mysql_db=/var/lib/mysql
Answer the question
In order to leave comments, you need to log in
Thanks a lot for the informative replies. You helped me a lot! :)
Summing up the experience:
All containers launched via docker-compose.yml are in the same virtual network and perfectly see each other by name.
Some complications arise when it requires an "external" container to run from another docker-compose.yml. By default, it is in a different virtual network and does not see other containers by name.
An explicit network declaration comes to the rescue.
networks:
pgsql_net:
name: pgsql_net
networks:
my_net:
external:
name: pgsql_net
..................
networks:
-my_net
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question