docker container port mapping and access each other

Port Mapping

If no run-time container port, it is unable to communicate with the outside world, such as we currently have a MySQL a docker container, the container is currently running mysql and provide port 3306

# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
2e54153e56ca        mysql:version1      "/bin/bash"         8 days ago          Up About a minute                       mysql-new-container

# docker exec -it mysql-new-container /bin/bash -c "netstat -antlp |grep 3306"
tcp6       0      0 :::3306                 :::*                    LISTEN      -                   

At this point we do not do port mapping, so the host and the outside world are unable to access the MySQL services

Guess you like

Origin www.cnblogs.com/ilifeilong/p/11784630.html