How to view the parent-child relationship of docker containers
This article mainly explains "how to view the parent-son relationship of docker container". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to view the parent-son relationship of docker container".
The docker connection creates a parent-child relationship where the parent container can see the information of the child container. When we create a container, docker automatically names it. Alternatively, we can use the-name flag to name the container.
Spring and springmvc are usually used in projects, but they are not in the same container. As we all know, the spring container can obtain objects from the container, spring and springmvc are parent-child container relationships, and springmvc can obtain the objects in the spring container, otherwise it cannot.
What do we do with the container?
We find that the two containers connected are father-son relationship. For example, the named containers are db and web, and we can see that the web container also displays db/web in the name column. This tells us that the web container and the db container are parent / child relationships. The parent container here is db, and you can access the child container web.
To do this, docker opens a secure connection tunnel between container services without exposing any ports outside the container. You will notice that when starting the db container, we did not use the-P or-p flag. When connecting to the container, you do not need to open the port to the PostgreSQL database over the network.
Docker exposes child container connection information in the parent container in two ways: environment variables and update / etc/hosts files.
Thank you for your reading, the above is the content of "how to view the parent-son relationship of docker containers". After the study of this article, I believe you have a deeper understanding of how to view the father-son relationship of docker containers. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!