Data volumeWhen talking about anonymous mount and named mount, we should first know what volumes are. Volumes refer to data volumes. We will use this volume for docker mount. The purpose of a data volume is to create a special directory that can be used by one or more containers. It bypasses UFS, which is a union file system, and provides many functions: The command to view the data volume can be used: docker volume --help In fact, the command content is not much as follows: In fact, you don't need to create a volume beforehand. You name it when you mount it. If it can't be found, a new data volume with a name instead of a hash code will be created based on the name you gave. Anonymous and named mountsWith the previous knowledge about volumes, we can actually know the difference between anonymous mount and named mount. One is a mount without a volume name, and the other is a mount with a specified volume name. For example, following the last mount, we specified the mount path. In fact, we can mount it more simply by not specifying the host path, and directly mount the docker container path with -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 anonymously mounted data volume. You can also find the corresponding data volume based on this hash code. It is anonymous to you, but people will actually give it a name. We can use the volume ls command to view what data volumes are available. docker volume ls This named mount needs to specify the data volume, similar to the previous specified path mount, but this time we do not use a specific specified path but the name of the data volume. # VOLUME NAME is currently displayed as an anonymous data volume. When -v is mounted, only the path in the container is written, not the path on the host. # Named mount # Pass -v volume name: path in the container docker run -d -P --name nginx02 -v juming-nginx:/etc/nginx nginx Location of the data volumeNow that we have set up specific data volumes, mounted containers, and know the purpose of data volumes, where are the data volumes? After all, everything that is mounted is there, so just take a look at where it is to avoid accidentally deleting it. In fact, the specific path under docker is: /var/lib/docker/volumes/xxxx/_data We can cd to this path to look at the data volume. For example, I cd to the second named data volume directory where nginx is mounted to look at the specific structure. Let's summarize the ways we mount: How to determine whether it is a named mount, an anonymous mount, or a specified path mount? # Use -v to set the path in the container: ro rw to change the read and write permissions # ro readonly read only # rw readwrite read and write # If container permissions are set, the container will have limited permissions on the mounted data. docker run -d -P --name nginx04 -v juming-nginx:/etc/nginx:ro nginx docker run -d -P --name nginx04 -v juming-nginx:/etc/nginx:rw nginx # ro Whenever you see ro, it means that this path can only be operated through the host machine, and cannot be operated inside the container This is the end of this article about the specific use of Docker anonymous mount and named mount. For more relevant Docker anonymous mount and named mount content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: The difference between the four file extensions .html, .htm, .shtml and .shtm
>>: Complete MySQL Learning Notes
What is k3d? k3d is a small program for running a...
I have been playing around with charts for a whil...
First, I will give you the VMware 14 activation c...
When people are working on a backend management s...
This article describes how to use the local yum s...
Automatic backup of MySQL database using shell sc...
Table of contents Common functions of linux drive...
Last night, I was looking at an interview question...
This article introduces blue-green deployment and...
Get the Dockerfile from the Docker image docker h...
Table of contents 1. MySQL replication process 2....
Docker Compose Docker Compose is a tool for defin...
Table of contents Preface What is index pushdown?...
MySQL installation instructions MySQL is a relati...
1. First register your own dockerhub account, reg...