In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to visit Service. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
We have learned how to deploy service and verified the failover feature of swarm. So far, however, there is an important question that has not been addressed: how to access service?
For ease of analysis, we redeploy web_server.
① docker service rm Delete all copies (containers) of web_server,service are deleted.
② recreates the service, this time creating two copies directly with-- replicas=2.
③ runs a copy on each worker node.
Well, now that service is there, how can we access it?
To access the http service, at least the network is available, and we need to know the IP of the service, but we don't know any of this information at present. But at least we know that each copy is a running container, so let's take a look at the container's network configuration first.
A container is running on swarm-worker1, which is a copy of web_server. The container listens on port 80, but does not map to Docker Host, so it can only be accessed through the container's IP. Check the IP of the container.
The container IP is 172.17.0.2, which is actually connected to the Docker default bridge network.
We can access the container's http service directly on swarm-worker1.
However, such access is only at the container level, and the service is not exposed to the external network and can only be accessed on the Docker host. In other words, we cannot access service web_server under the current configuration.
Access service from outside
To expose the service to the outside world, the method is actually very simple, execute the following command:
Docker service update-- publish-add 8080 web_server
If you create a new service, you can directly use the-- publish parameter, such as:
Docker service create-- name web_server-- publish 8080-- replicas=2 httpd
The container listens for http requests on port 80, which maps 80 of the container to port 8080 of the host, so that the external network can access the service.
You may wonder why port 8080 of any node in the curl cluster can access web_server?
This is actually the benefit of using swarm, a feature called routing mesh.
The above is the editor for you to share how to access Service, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, 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.