Access to mysql container from other container

前端 未结 3 1751
执笔经年
执笔经年 2020-12-15 18:29

I have setup docker container with mysql that expose 3306. I\'ve specified database user, database password and create a test db and give the privileges to new user.
In

3条回答
  •  孤街浪徒
    2020-12-15 18:43

    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.

提交回复
热议问题