mirror of https://github.com/docker/docker-py.git
Merge pull request #34 from ehazlett/privileged-containers
added privileged container support
This commit is contained in:
commit
6dff1efde7
|
@ -21,7 +21,7 @@ Identical to the `docker commit` command.
|
|||
* `c.containers(quiet=False, all=False, trunc=True, latest=False, since=None, before=None, limit=-1)`
|
||||
Identical to the `docker ps` command.
|
||||
|
||||
* `c.create_container(image, command, hostname=None, user=None, detach=False, stdin_open=False, tty=False, mem_limit=0, ports=None, environment=None, dns=None, volumes=None, volumes_from=None)`
|
||||
* `c.create_container(image, command, hostname=None, user=None, detach=False, stdin_open=False, tty=False, mem_limit=0, ports=None, environment=None, dns=None, volumes=None, volumes_from=None, privileged=False)`
|
||||
Creates a container that can then be `start`ed. Parameters are similar to those
|
||||
for the `docker run` command except it doesn't support the attach options
|
||||
(`-a`)
|
||||
|
|
|
@ -100,7 +100,8 @@ class Client(requests.Session):
|
|||
|
||||
def _container_config(self, image, command, hostname=None, user=None,
|
||||
detach=False, stdin_open=False, tty=False, mem_limit=0, ports=None,
|
||||
environment=None, dns=None, volumes=None, volumes_from=None):
|
||||
environment=None, dns=None, volumes=None, volumes_from=None,
|
||||
privileged=False):
|
||||
if isinstance(command, six.string_types):
|
||||
command = shlex.split(str(command))
|
||||
if isinstance(environment, dict):
|
||||
|
@ -121,6 +122,7 @@ class Client(requests.Session):
|
|||
'Image': image,
|
||||
'Volumes': volumes,
|
||||
'VolumesFrom': volumes_from,
|
||||
'Privileged': privileged,
|
||||
}
|
||||
|
||||
def _mkbuildcontext(self, dockerfile):
|
||||
|
@ -269,10 +271,11 @@ class Client(requests.Session):
|
|||
|
||||
def create_container(self, image, command, hostname=None, user=None,
|
||||
detach=False, stdin_open=False, tty=False, mem_limit=0, ports=None,
|
||||
environment=None, dns=None, volumes=None, volumes_from=None):
|
||||
environment=None, dns=None, volumes=None, volumes_from=None,
|
||||
privileged=False):
|
||||
config = self._container_config(image, command, hostname, user,
|
||||
detach, stdin_open, tty, mem_limit, ports, environment, dns,
|
||||
volumes, volumes_from)
|
||||
volumes, volumes_from, privileged)
|
||||
return self.create_container_from_config(config)
|
||||
|
||||
def create_container_from_config(self, config):
|
||||
|
|
|
@ -131,6 +131,13 @@ class TestCreateContainerWithBinds(BaseTestCase):
|
|||
os.unlink(shared_file)
|
||||
self.assertIn(filename, logs)
|
||||
|
||||
class TestCreateContainerPrivileged(BaseTestCase):
|
||||
def runTest(self):
|
||||
res = self.client.create_container('busybox', 'true', privileged=True)
|
||||
inspect = self.client.inspect_container(res['Id'])
|
||||
self.assertIn('Config', inspect)
|
||||
self.assertEqual(inspect['Config']['Privileged'], True)
|
||||
|
||||
class TestStartContainer(BaseTestCase):
|
||||
def runTest(self):
|
||||
res = self.client.create_container('busybox', 'true')
|
||||
|
|
Loading…
Reference in New Issue