In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
It is believed that many inexperienced people don't know what to do about how to map the port of docker container. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Docker port mapping is to map the service ports applied in the container to the host machine. When some network applications are running in the container, the port mapping can be specified by-P or-p parameters to allow external access to these applications.
1. Random mapping. When using the-P parameter, the docker container will randomly map a port to a network port open by the internal container.
two。 Specify the port, and when using the-p parameter, you can specify the port to be mapped, and only one container can be bound on a specified port.
3. Look at the mapped port, use the docker port command to see the currently mapped port configuration, and you can also see the bound address.
Method one
1. Get the container IP
Change the container_name to the container name in the real environment
Docker inspect `container_ name` | grep IPAddress
2. Iptable forwarding port
Map port 8000 of the container to port 8001 of the docker host
Iptables-t nat-A DOCKER-p tcp-- dport 8001-j DNAT-- to-destination 172.17.0.19 tcp 8000
Method two
1. Submit a running container as an image
Docker commit containerid foo/live
two。 Run the mirror and add a port
Docker run-d-p 8000UR 80 foo/live / bin/bash
After reading the above, have you mastered how docker containers map ports? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.