Under the Docker network - custom network combat

 Through the study of the previous two articles, we understand the docker network and the four major network types. In this article, let's learn about docker's custom network. Why do we need a custom network? It is to keep each host in categories and organized. It is convenient for association, so that networks can communicate through service names. Why in the container, do we need to communicate through the service name? That's because the IP inside the docker container may change. We use a custom network to solve the problem of direct network communication through the service name without being affected when the container IP changes.

Let's take a look before using a custom network:

In the previous article, our case used tomcat81 and tomcat82. We started these two containers. Use the command:

docker run -d -p 8081:8080 --name tomcat81 billygoo/tomcat-jdk8

Start both Tomcats, let's docker ps to see

OK, both Tomcats are started successfully. We enter the interior of the respective container instance respectively. Use the command docker exec -it tomcat81 bash. After entering the service, let's test two situations. 1: Two containers are related to pi through IP

Guess you like

Origin blog.csdn.net/kaizi_1992/article/details/128479726