I have pulled an MYSQL image from Docker Hub and ran it by setting necessary credentials, such as username, password etc. Then I have inspected the container by:
docker inspect CONTAINER_ID
where I got the IP address for the MySQL databese. Since the Docker deamon connect through bridge network, my IP addess was: 172.17.0.2. By specifying this IP I can connnect to the Database from the host computer(Fedora). But, how do I connectd to the MySQL database from another machine in the same LAN?
答案 0 :(得分:1)
您需要将容器端口绑定到主机端口。将-p
添加到docker run
命令:
docker run -p HOST_PORT:CONTAINER_PORT
即:
docker run -p 3306:3306 .......
因此可以从Fedora的LAN界面获得MySQL。