Skip to content

bind mounts can't be altered #541

@terminalmage

Description

@terminalmage

The binds argument to docker.client.Client.start() is ignored after the first time it is set.

>>> client.create_container(name='foo', image='busybox', volumes=['/var/www'])
{u'Id': u'de68703bd394d229a6a8ce26a2efc3ab2b6cdf1b055a8b8c192ff54fc2373eff', u'Warnings': None}
>>> client.start('foo', binds={'/home/erik/foo': {'bind': '/var/www', 'ro': True}})
>>> client.inspect_container('foo')['VolumesRW']
{u'/var/www': False}
>>> client.stop('foo')
>>> client.start('foo', binds={'/home/erik/foo': {'bind': '/var/www', 'ro': False}})
>>> client.inspect_container('foo')['VolumesRW']
{u'/var/www': False}

If I re-make the container, I can now set read-only to False:

>>> client.stop('foo')
>>> client.remove_container('foo')
>>> client.create_container(name='foo', image='busybox', volumes=['/var/www'])
{u'Id': u'7fcbe284494a33f15e523d778dc1bc66e975d56f93baa524f1ccbb7f13527ea4', u'Warnings': None}
>>> client.start('foo', binds={'/home/erik/foo': {'bind': '/var/www', 'ro': False}})
>>> client.inspect_container('foo')['VolumesRW']
{u'/var/www': True}
>>>

Is this by design? My knowledge of the inner-workings of Docker is limited. If the binds are not designed to be altered, then this should be properly documented, and a warning should be issued when one attempts to set binds after they've been initially set.

Additional information:

>>> pprint.pprint(client.version())
{u'ApiVersion': u'1.17',
 u'Arch': u'amd64',
 u'GitCommit': u'a8a31ef',
 u'GoVersion': u'go1.4.1',
 u'KernelVersion': u'3.19.2-1-ARCH',
 u'Os': u'linux',
 u'Version': u'1.5.0'}
>>> docker.version
'1.1.0'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions