Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to share data with volume container

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to share data with volume container. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Volume container is a container that specifically provides volume for other containers. The volume it provides can be either bind mount or docker managed volume.

Let's create a volume container:

We named the container vc_data (vc is an abbreviation for volume container). Note that the docker create command is executed here, because the purpose of volume container is to provide data, and it does not need to be running by itself. The container mount contains two volume:

Bind mount, which stores the static file of web server.

Docker managed volume, which stores some utilities (it's empty now, of course, and this is just an example).

These two volume can be seen through docker inspect.

# docker inspect vc_data

.

"Mounts": [

{

"Source": "/ root/htdocs"

"Destination": "/ usr/local/apache2/htdocs"

"Mode":

"RW": true

"Propagation": "rprivate"

}

{

"Name": "1b603669398d117e499449862636a56c4f4c804d447c680e7b3ba7c7f5e52205"

"Source": "/ var/lib/docker/volumes/1b603669398d117e499449862636a56c4f4c804d447c680e7b3ba7c7f5e52205/_data"

"Destination": "/ other/useful/tools"

"Driver": "local"

"Mode":

"RW": true

"Propagation":

}

]

.

Other containers can use the vc_data volume container through-- volumes-from

All three httpd containers use vc_data to see what volume they all have now. Take web1 as an example:

# docker inspect web1

.

"Mounts": [

{

"Source": "/ root/htdocs"

"Destination": "/ usr/local/apache2/htdocs"

"Mode":

"RW": true

"Propagation": "rprivate"

}

{

"Name": "1b603669398d117e499449862636a56c4f4c804d447c680e7b3ba7c7f5e52205"

"Source": "/ var/lib/docker/volumes/1b603669398d117e499449862636a56c4f4c804d447c680e7b3ba7c7f5e52205/_data"

"Destination": "/ other/useful/tools"

"Driver": "local"

"Mode":

"RW": true

"Propagation":

}

]

.

The web1 container uses vc_data 's volume, and even mount point is the same.

As you can see, the three containers have successfully shared the volume in volume container.

Let's discuss the characteristics of volume container:

Compared with bind mount, it is not necessary to specify host path for each container, all path is defined in volume container, and the container only needs to be associated with volume container, which realizes the decoupling of container and host.

The mount point of the container using volume container is consistent, which is conducive to the specification and standardization of configuration, but it also brings some limitations, which need to be taken into account.

After reading the above, do you have any further understanding of how to share data with volume container? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report