Skip to content

Conversation

shin-
Copy link
Contributor

@shin- shin- commented Apr 6, 2017

Also includes some cleanup in ContainerConfig + warning if volume_driver is provided (API>1.20)

Fixes #1543

Some cleanup in ContainerConfig + warning if volume_driver is provided (API>1.20)

Signed-off-by: Joffrey F <joffrey@docker.com>
@mxylin
Copy link

mxylin commented Apr 17, 2017

Hi @shin- thanks for the fix. I've tested the master branch and here's some results (when creating a container on swarm/1.2.6 with a named volume and a specified volume driver)

  1. Success, if using low-level APIClient.
    Container ubuntu-test is created, a new named volume testvol is created using the specified volume driver convoy
import docker
client = docker.APIClient(base_url='tcp://swarm:2375',version='1.24')
container_id = client.create_container(
image='ubuntu', 
command='uname', 
name='ubuntu-test', 
volumes=['/mnt/vol1'], 
host_config=client.create_host_config(binds=['testvol:/mnt/vol1'],volume_driver='convoy')
)
  1. Fail, if using high-level DockerClient.
    Container ubuntu-test is created, a new named volume testvol is created using the local driver, this is an unexpected result.
import docker
client = docker.DockerClient(base_url='tcp://swarm:2375',version='1.24')
container = client.containers.create(
image='ubuntu', 
command='uname', 
name='ubuntu-test', 
volume_driver='convoy', 
volumes={'testvol': {'bind': '/mnt/vol', 'mode': 'rw'}}
)

For the issue regarding DockerClinet, I see volume_driver is currently defined in the RUN_CREATE_KWARGS list (https://github.com/docker/docker-py/blob/master/docker/models/containers.py#L793). I guess moving it to the RUN_HOST_CONFIG_KWARGS might solve the issue, but I'm not quite sure yet how this affects backward compatibility for API versions 1.19 and 1.20.

Thanks!

@mxylin
Copy link

mxylin commented Jul 17, 2019

Fixed in #2288

Related issue: #2271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The VolumeDriver was moved from config to HostConfig since Engine API v1.21

2 participants