table of Contents
Named and anonymous mount
Anonymous mount
- Only specify the inside of the container, not specify the outside of the container
docker run -d -P --name nginx01 -v /etc/nginx nginx
-v path in the container Do not write the path on the host, it will automatically create a path -P Capital P, specify the port randomly docker volume command
- It can be found that the name of the volume is a string of characters, which is an anonymous mount
- In -v, only the path inside the container is written, and the path outside the container is not written
Named mount
- Name the volume by -v volume name: path in the container
docker run -d -P --name nginx02 -v juming-nginx:/etc/nginx nginx
- View the specific location of the volume name
docker volume inspect juming-nginx
- All the volumes in the docker container are in : /var/lib/docker/volumes/xxxx/_data without specifying a directory
- We can easily find one of our volumes through named mounting . In most cases, we are also using named mounting
- So the question is, how do we determine whether it is a named mount, an anonymous mount, or a specified path mount?
-v path in the container Anonymous mount -v volume name: path in the container Named mount -v /host path: path in the container Specify the path to mount, pay attention to /
- note
- Sometimes we will encounter such a command, the path is followed by a ro or rw
docker run -d -P --name nginx02 -v juming-nginx:/etc/nginx:ro nginx docker run -d -P --name nginx02 -v juming-nginx:/etc/nginx:rw nginx
- Once the permissions of the container are set, the container will limit the content we mount
- ro As long as you see ro, it means that this path can only be operated by the host, and the inside of the container cannot be operated. The default is rw
(Docker notes): named mount and anonymous mount
Guess you like
Origin blog.csdn.net/baidu_41388533/article/details/108561283
Ranking