In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you Docker how to use anonymous mount and named mount, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Data volume volume
Mention this anonymous mount and named mount, in fact, we should first popularize a knowledge, that is, what is volumes, this volumes means data volume. We will use this volume for docker mounts.
The purpose of a data volume is a special directory that can be used by one or more containers, bypassing what UFS is a federated file system and providing a lot of functionality:
(1) data volumes can be shared or reused by multiple containers
(2) the modification to the data volume will take effect immediately
(3) updates to the data volume will not affect the mirror image
(4) the data volume will always exist by default, even if the container is deleted (the combination of 2 and 3 points is very similar to nacos)
The command to view data volumes can be used:
Docker volume-help
In fact, the contents of the command are as follows:
In fact, you don't have to create a volume before you create it. If you name it when you mount it, if you can't find it, you will create a new volume volume with a name instead of a hash code based on the name you gave.
Anonymous mount and named mount
With the supplement of the previous data volume volume knowledge, you can actually know if you mount it anonymously and with a life. One is the mount that does not give the data volume name, and the other is the mount that specifies the data volume name.
For example, in the last mount, we specified the specified path to mount. In fact, we can mount it more easily. If the specified path of the host is not given, the path of the docker container can be mounted directly-v. Install nginx anonymously as follows.
# Anonymous mount-P uppercase P, map random port-v container path docker run-d-P-- name nginx01-v / etc/nginx nginx
In fact, a hash code will be returned, which is the name of the data volume mounted anonymously. You can also find the corresponding data volume according to this hash code. It is anonymous to you, but people will actually give you a name. We can use the volume ls command to see what data volumes are available.
Docker volume ls
Then this named mount should specify the data volume, which is similar to the path mount we specified before, but we do not apply the specific specified path but the name of the data volume.
# VOLUME NAME is currently displayed as an anonymous data volume. When mounting on-v, only the path in the container is written, but not the path to the host. # mount with a name # through-v volume name: the location of the docker run-d-P-- name nginx02-v juming-nginx:/etc/nginx nginx data volume in the container.
Now that we have set up a specific data volume, mounted the container, and know the use of the data volume, where is the data volume? After all, all the mounted things are there, take a look at where the location is to avoid being mistakenly deleted.
In fact, his specific path to docker is as follows:
/ var/lib/docker/volumes/xxxx/_data
We can cd to this path to take a look at the data volume, for example, I cd to the second named mount nginx data volume directory to take a look at the specific structure.
Summarize the ways we mount it:
How to determine whether to mount it anonymously or anonymously, or specify a path?
-v path in container # anonymous mount
-v data volume name: / path in the container # mount with name
-v / host path: / path within the container # specify path to mount
# change the read and write permissions through-v container path: ro rw # ro readonly read only # rw readwrite read and write # if the container permission is set, the container has the permission to limit the mounted data. Docker run-d-P-- name nginx04-v juming-nginx:/etc/nginx:ro nginxdocker run-d-P-- name nginx04-v juming-nginx:/etc/nginx:rw nginx# ro as soon as you see the ro, it means that this path can only be operated through the host, but cannot be operated inside the container. The above is all the contents of the article "how to mount Docker anonymously and anonymously". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.