How to check the folders and files in the Docker volume.
docker volume inspect
.Checking the mount point of volume
#Display volume list
docker volume ls
#Check mount point
docker volume inspect [Volume name]
Start a container with root privileges and check the contents of the volume
#Start container with root authority
$ docker run -it --privileged --pid=host [Image name] nsenter -t 1 -m -u -n -i sh
#Show the contents of the volume
/ # ls [Absolute path of mountpoint]
#End interactive mode
/ # exit
With the above operation, the contents of volume can be confirmed.
Check the image
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest 35064a4fcc93 2 weeks ago 648MB
django_web latest 7f0eff7ebc94 2 weeks ago 937MB
debian latest 1510e8501783 5 weeks ago 114MB
python 3 dfc47c6cee13 6 weeks ago 886MB
postgres latest 817f2d3d51ec 7 weeks ago 314MB
vuecli 3 4040959eab16 2 months ago 338MB
Display volume list
$ docker volume ls
DRIVER VOLUME NAME
local 0adf7a2b08b8e09f74ffb7799716e48263f012612dc2047da1d7137a75f12b5d
local vuecli3_vue-cli-node-volume
Check mount point
$ docker volume inspect vuecli3_vue-cli-node-volume
[
{
"CreatedAt": "2020-09-08T05:35:36Z",
"Driver": "local",
"Labels": {
"com.docker.compose.project": "vuecli3",
"com.docker.compose.version": "1.26.2",
"com.docker.compose.volume": "vue-cli-node-volume"
},
"Mountpoint": "/var/lib/docker/volumes/vuecli3_vue-cli-node-volume/_data",
"Name": "vuecli3_vue-cli-node-volume",
"Options": null,
"Scope": "local"
}
]
Enter docker interactive mode
$ docker run -it --privileged --pid=host [Image name] nsenter -t 1 -m -u -n -i sh
docker interactive mode
/ # ls
EFI boot dev home lib mnt proc run srv tmp var
bin containers etc init media opt root sbin sys usr
Check volume
/ # ls /var/lib/docker/volumes/micres_micres-node_modules2/_data
@babel mime-db
@csstools mime-types
@mdi mimic-response
@nicolo-ribaudo mini-css-extract-plugin
@npmcli minimalistic-assert
@rails minimalistic-crypto-utils
What is the most important command to start a container with root privileges?
Command $ docker run -it --privileged --pid = host [image name] nsenter -t 1 -m -u -n -i sh`
・ -It
-t pseudo terminal (--tty)
-i Standard output always ON (--interactive)
・ --Privileged
Privileged mode. Launch a special container with root privileges on the host.
・ --Pid = host
--pit = Specify the PID namespace for the container.
Use the host-side PID namespace inside the host container.
・ Nsenter
A command line tool for entering namespaces created with Docker.
A combination of acronyms for "ENTER into Name Spaces".
・ -M
"--Mount" Enter the mount name space. If no namespace is specified, the process specified by PID will be used.
・ ` ` Enter the "-uts" UTS namespace. If no namespace is specified, the process specified by PID will be used.
uts stands for Unix Time Sharing.
・ ` ` Enter the "--net" network namespace. If no namespace is specified, the process specified by PID will be used.
・ -I
Enter the "--ipc" IPC namespace. If no namespace is specified, the process specified by PID will be used.
In short, it seems that various namespaces will be launched by processing PID = 1.
Recommended Posts