I am trying to connect a phpmyadmin container to another mysql container. I have created a network with docker network create
and added my two containers. But when I tried to login with phpmyadmin, the password is incorrect error displayed each time.
I checked that the two containers are available to my networks which I already created so I tried to ping
mysql container to phpmyadmin container but unfortunately I had negative results.
I followed this tutorial:
https://tecadmin.net/tutorial/docker/docker-networking-example/
Can you explain to me how the commend docker run --network
works exactly ?
If everything is ok, so you can ping
one container from another using container name. When you create a network between 2 containers, it creates an alias with the container name and the container IP.
For instance
docker network create my-bridge-network
docker run --name mysql -e MYSQL_ROOT_PASSWORD=secret -d mysql/mysql-server --network my-bridge-network
docker run --name phpmyadmin -d -e PMA_HOST=mysql -p 8080:80 phpmyadmin/phpmyadmin --network my-bridge-network
In this case when you exec
ping
from phpmyadmin
container you should be able to ping mysql
container
docker exec phpmyadmin ping mysql # if in phpmyadmin `ping` program is available