list.sh
$ docker volume ls
du667382djcn ・ ・ ・
hy66557738mj ・ ・ ・
examplevolume
examplevolume2
Random numbers like du6673 displayed here Volume may be automatically generated for some reason. When pulling a container, starting, etc. within my own recognition range The line is cut, the mount or the file in the image is directly tampered with, etc. I feel that it often happens for some reason. (If you have any experiences that it will be automatically generated at such times, I would be grateful if you could comment)
run.sh
$ docker run -itd --name testvolume -v du667382djcn:/du667382djcn busybox
As a command structure docker run -itd --name Container name here -v Volume name here: / Freely set the directory name inside the container when attaching a volume inside the container busybox (← image. Busybox is a lightweight Linux command Group image)
It will be shaped like.
Note) Note that an error will occur if the / slash is omitted.
exec.sh
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a23fd4z8ks2d busybox "sh" 8 seconds ago Up 7 seconds testvolume
$ docker exec -it a23fd4z8ks2d /bin/ash
/ # ls -la
total 48
drwxr-xr-x 1 root root 4096 Apr 10 03:19 .
drwxr-xr-x 1 root root 4096 Apr 10 03:19 ..
-rwxr-xr-x 1 root root 0 Apr 10 03:19 .dockerenv
drwxr-xr-x 2 root root 12288 Jul 16 2019 bin
drwxr-xr-x 5 root root 360 Apr 10 03:19 dev
drwxr-xr-x 2 root root 4096 Nov 11 10:03 du667382djcn
drwxr-xr-x 1 root root 4096 Apr 10 03:19 etc
drwxr-xr-x 2 nobody nogroup 4096 Jul 16 2019 home
dr-xr-xr-x 190 root root 0 Apr 10 03:19 proc
drwx------ 1 root root 4096 Apr 10 03:20 root
dr-xr-xr-x 13 root root 0 Apr 10 03:19 sys
drwxrwxrwt 2 root root 4096 Jul 16 2019 tmp
drwxr-xr-x 3 root root 4096 Jul 16 2019 usr
drwxr-xr-x 4 root root 4096 Jul 16 2019 var
$ls -la /du667382djcn
This will bring up a list of the mounted directories.
I tried the following method with reference to the information a while ago, but it didn't work.
error.sh
$ docker volume ls
du667382djcn ・ ・ ・
hy66557738mj ・ ・ ・
examplevolume
examplevolume2
$ docker volume inspect du667382djcn
[
{
"CreatedAt": "2017-11-11T10:13:45Z",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/du667382djcn ・ ・ ・/_data",
"Name": "du667382djcn ・ ・ ・",
"Options": null,
"Scope": "local"
}
]
$ sudo ls -la /var/lib/docker/volumes/du667382djcn ・ ・ ・/_data
ls: /var/lib/docker/volumes/du667382djcn ・ ・ ・/_data: No such file or directory
It would be easier if this method could be done. I would appreciate it if you could comment on any of the above mistakes or similar practices.
Recommended Posts