In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article shows you how to modify the docker container port, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Docker port mapping is to map the service ports applied in the container to the host machine.
Port mapping when creating a container
Docker run-d-p 80:80-name name
To replace the container, you need to stop the container
$docker stop A $docker commit An imageA$ docker rm A $docker run-d-p 80:80-name An imageA
To modify the configuration of the container, you need to restart the DOCKER service, otherwise it will fail.
1. Stop the container, stop the service (systemctl stop docker/service docker stop)
$docker stop A $systemctl stop docker
two。 Modify / var/lib/docker/containers/ {Container ID+ some strings} / hostconfig.json
"PortBindings": {"container port / tcp": [{"HostIp": "", "HostPort": "host port"}]
At the same time, modify "ExposedPorts": {"Container Port / tcp": {}} in config.v2.json in the same directory.
"Ports": {"Container port / tcp": [{"HostIp": "0.0.0.0", "HostPort": "host port"}]}
3. Restart the service and start the container (systemctl start docker/service docker start)
$systemctl start docker$ docker start A
Add a mapping when the container is running
Iptables-t nat-A DOCKER-p tcp-- dport host port-j DNAT-- to-destination container ip: container port
View Container ip
Docker inspect-- format=' {{.NetworkSettings.IPAddress}}'$(docker ps-a-Q)
The above content is how to modify the docker container port, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.