Access to mysql container from other container

The --link flag is considered a legacy feature, you should use user-defined networks.

You can run both containers on the same network:

docker run -d --name php_container --network my_network my_php_image

docker run -d --name mysql_container --network my_network my_mysql_image

Every container on that network will be able to communicate with each other using the container name as hostname.

Leave a Comment