You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I mount a volume or host path to /var/lib/docker inside a container, using docker-py: >>> client.containers.run('alpine', volumes=['my_volume:/var/lib/docker']) ,
a very strange behavior occurs:
My volume (or host path) is mounted as expected to /var/lib/docker (so far, so good)
However, another docker volume with long cryptic name is created automatically
This additional volume is mounted to: /var/lib/docke [sic!] - without the trailing "r"!
This new volume is empty and stays empty, since it is not expected and not used. However, it remains after the container is stopped and removed.
While this does not actually break any functionality, it leads to a lot of useless volumes accumulating on my system. And these are not easy to filter from other, also automatically created volumes, that I actually still need, so cleaning up is very tedious.
This is apparently a problem of docker-py, not of docker itself: when doing the same using docker CLI everything works as expected: $ docker run -v my_volume:/var/lib/docker alpine
The specific use case where I would like to mount a volume to that path is the docker:dind image from the official docker library. It requires /var/lib/docker to be a volume in its Dockerfile. I want to provide my own volume (or host path) for this, so I can manage and re-use the docker cache.
Logs / Inspects
Inspect container (shortened to relevant part) clearly shows the two mount paths:
Shell into affected container clearly shows that both dirs exist, but only one is in use:
~ # ls -la /var/lib/docker
total 56
drwx--x--- 14 root root 4096 Mar 29 21:03 .
drwxr-xr-x 1 root root 4096 Mar 29 21:03 ..
drwx--x--x 4 root root 4096 Mar 29 21:03 buildkit
drwx--x--x 3 root root 4096 Mar 29 21:03 containerd
drwx--x--- 2 root root 4096 Mar 29 21:03 containers
drwx------ 3 root root 4096 Mar 29 21:03 image
drwxr-x--- 3 root root 4096 Mar 29 21:03 network
drwx--x--- 3 root root 4096 Mar 29 21:03 overlay2
drwx------ 4 root root 4096 Mar 29 21:03 plugins
drwx------ 2 root root 4096 Mar 29 21:03 runtimes
drwx------ 2 root root 4096 Mar 29 21:03 swarm
drwx------ 2 root root 4096 Mar 29 21:03 tmp
drwx------ 2 root root 4096 Mar 29 21:03 trust
drwx-----x 2 root root 4096 Mar 29 21:03 volumes
~ # ls -la /var/lib/docke
total 8
drwxr-xr-x 2 root root 4096 Mar 29 21:03 .
drwxr-xr-x 1 root root 4096 Mar 29 21:03 ..
Version information
$ pip freeze | grep docker && python --version && docker version
docker==5.0.3
Python 3.8.10
Client:
Version: 20.10.7
API version: 1.41
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5~20.04.2
Built: Mon Nov 1 00:34:17 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.8
Git commit: 20.10.7-0ubuntu5~20.04.2
Built: Fri Oct 22 00:45:53 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.5-0ubuntu3~20.04.2
GitCommit:
runc:
Version: 1.0.1-0ubuntu2~20.04.1
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:
Host OS:
ubuntu Linux 20.04
Kernel 5.4.0-104-generic x86_64
Please let me know if I can provide any more information.
The text was updated successfully, but these errors were encountered:
orbelico
changed the title
Using a mount-point which is also specified in Dockerfile results in creation of invalid and useless volumes
Mounting to /var/lib/docker results in creation of invalid and useless volumes
Mar 29, 2022
This seems related to #3073. Try working that around by supplying a volumes dict instead of list. It will bypass this step and not call the problematic function (this line).
Short description and how to reproduce
If I mount a volume or host path to
/var/lib/docker
inside a container, using docker-py:>>> client.containers.run('alpine', volumes=['my_volume:/var/lib/docker'])
,a very strange behavior occurs:
/var/lib/docker
(so far, so good)var/lib/docke
[sic!] - without the trailing "r"!While this does not actually break any functionality, it leads to a lot of useless volumes accumulating on my system. And these are not easy to filter from other, also automatically created volumes, that I actually still need, so cleaning up is very tedious.
This is apparently a problem of docker-py, not of docker itself: when doing the same using docker CLI everything works as expected:
$ docker run -v my_volume:/var/lib/docker alpine
The specific use case where I would like to mount a volume to that path is the
docker:dind
image from the official docker library. It requires/var/lib/docker
to be a volume in its Dockerfile. I want to provide my own volume (or host path) for this, so I can manage and re-use the docker cache.Logs / Inspects
Inspect container (shortened to relevant part) clearly shows the two mount paths:
Inspect the invalidly created volume:
Shell into affected container clearly shows that both dirs exist, but only one is in use:
Version information
Host OS:
Please let me know if I can provide any more information.
The text was updated successfully, but these errors were encountered: