In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to access the Docker container in the outside world. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
How does the external network access the container?
The answer is: Port mapping.
Docker can map the port on which the container provides services to a port in host, through which the public network accesses the container. When the container starts, the port is mapped with the-p parameter:
After the container is started, the port mapped by host can be found through docker ps or docker port. In the above example, port 80 of the httpd container is mapped to host 32773 so that the container's web service can be accessed through:.
In addition to mapping dynamic ports, you can also specify in-p to map to a specific port of host, for example, port 80 can be mapped to port 8080 of host:
For each mapped port, host starts a docker-proxy process to handle the traffic accessing the container:
The whole process is analyzed by taking 0.0.0.0 80/tcp 32773-> as an example:
Docker-proxy listens on port 32773 of host.
When curl accesses 10.0.2.15 32773, the docker-proxy forwards it to container 172.17.0.2 VR 80.
The httpd container responds to the request and returns the result.
We first learned about three kinds of Docker networks: none, host and bridge and discussed their different usage scenarios. Then we practiced creating a custom network. Finally, we discussed in detail how to communicate between containers and containers and between containers and external networks.
So much for sharing about how the outside world accesses the Docker container. I hope the above can help you and learn more. If you think the article is good, you can share it for more people to see.
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.