Skip to content

Instantly share code, notes, and snippets.

@elementalvoid
Last active August 29, 2015 14:02
Show Gist options
  • Save elementalvoid/629641c4e183d9c729eb to your computer and use it in GitHub Desktop.
Save elementalvoid/629641c4e183d9c729eb to your computer and use it in GitHub Desktop.
docker-py volume binding failure
import docker
client = docker.Client(base_url='unix://var/run/docker.sock', version='1.11', timeout=10)
client.pull('busybox', tag='latest')
container = client.create_container('busybox:latest', volumes=['/var/run/docker.sock'])
# This fails. It's based on https://github.com/dotcloud/docker-py#using-volumes
client.start(container, binds={'/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'ro': False}})
---------------------------------------------------------------------------
APIError Traceback (most recent call last)
<ipython-input-39-53b5ae26cbdd> in <module>()
----> 1 client.start(container, binds={'/var/run/docker.sock': {'bind': '/var/run/docker.sock', 'ro': False}})
/usr/local/lib/python2.7/dist-packages/docker/client.pyc in start(self, container, binds, port_bindings, lxc_conf, publish_all_ports, links, privileged)
740 url = self._url("/containers/{0}/start".format(container))
741 res = self._post_json(url, data=start_config)
--> 742 self._raise_for_status(res)
743
744 def stop(self, container, timeout=10):
/usr/local/lib/python2.7/dist-packages/docker/client.pyc in _raise_for_status(self, response, explanation)
113 response.raise_for_status()
114 except requests.exceptions.HTTPError as e:
--> 115 raise APIError(e, response, explanation=explanation)
116
117 def _result(self, response, json=False, binary=False):
APIError: 500 Server Error: Internal Server Error ("Cannot start container 29c79a8de096a2f9b0b8edbaf13e0c49e201bc11ce4dd03b86929633c6ed3094: Invalid bind specification: /var/run/docker.sock:{'bind': '/var/run/docker.sock', 'ro': False}")
@metalivedev
Copy link

Have you tried doing this with the docker CLI? That is, is it a docker.py problem or a general docker problem?
Have you tried giving the container "privileged" status? Not sure how to do this with docker.py. On the commandline it is --privileged.

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