docker-py v2.0.0 Can't create container data volumes using client.containers.run & create
See original GitHub issuehttps://docker-py.readthedocs.io/en/latest/containers.html: run method: for volumes it says:
volumes (dict or list) –
A dictionary to configure volumes mounted inside the container. The key is either the host path or a volume name, and the value is a dictionary with the keys:
bind The path to mount the volume inside the container
mode Either rw to mount the volume read/write, or ro to mount it read-only.
For example:
{'/home/user1/': {'bind': '/mnt/vol2', 'mode': 'rw'},
'/var/www': {'bind': '/mnt/vol1', 'mode': 'ro'}}
This effectively means that you can’t create container data volumes, since you either have to create a volume 1st using docker create volume or use a host directory. There is no option to just specify a container folder.
The low-level API (https://docker-py.readthedocs.io/en/latest/api.html#module-docker.api.container) create_container still allows you to do this (since I was able to do this using the v1 of docker-py
From the docker run documentation https://docs.docker.com/engine/reference/commandline/run/:
-v, --volume value Bind mount a volume (default []). The format
is `[host-src:]container-dest[:<options>]`.
The comma-delimited `options` are [rw|ro],
[z|Z], [[r]shared|[r]slave|[r]private], and
[nocopy]. The 'host-src' is an absolute path
or a name value.
Am I correct here that logic to support container data volumes is missing from client.containers.run & create? Or is there another way how to do this? Or are container data volumes being replaced by data volumes?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top GitHub Comments
I believe there is also a bug with named volumes not being supported by
DockerClient.containers.run
:(The volume had already been created with
docker volume create --name my-named-volume
.)Gosh, what a mess. Fixes for both things here: https://github.com/docker/docker-py/pull/1439
Sorry all!