A Python library for the Docker Engine API
Go to file
Raphaël De Giusti 579201bcf7 Fixed python26 shlex split of unicode strings.
Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> cmd = u"/bin/bash echo 'Hello World'"
>>> shlex.split(cmd)
['/\x00\x00\x00b\x00\x00\x00i\x00\x00\x00n\x00\x00\x00/\x00\x00\x00b\x00\x00\x00a\x00\x00\x00s\x00\x00\x00h\x00\x00\x00',
'\x00\x00\x00e\x00\x00\x00c\x00\x00\x00h\x00\x00\x00o\x00\x00\x00',
'\x00\x00\x00\x00\x00\x00H\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00
\x00\x00\x00W\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l\x00\x00\x00d\x00\x00\x00\x00\x00\x00']
>>> shlex.split(str(cmd))
['/bin/bash', 'echo', 'Hello World']
2013-08-14 08:27:42 +02:00
docker Fixed python26 shlex split of unicode strings. 2013-08-14 08:27:42 +02:00
tests Docker client now tries to load the auth config. This is necessary to use the push command if API version is >1.0 2013-08-06 19:57:20 +02:00
.gitignore Add python 3 support 2013-07-06 00:32:28 +10:00
ChangeLog.md Bumped to 0.1.4 2013-08-13 20:05:13 +02:00
LICENSE Add Apache 2.0 License 2013-08-07 11:39:59 -07:00
README.md Bumped to 0.1.4 2013-08-13 20:05:13 +02:00
requirements.txt pip needs "==" 2013-07-13 19:42:13 -04:00
setup.py Bumped to 0.1.4 2013-08-13 20:05:13 +02:00
tox.ini Add python 3 support 2013-07-06 00:32:28 +10:00

README.md

docker-py

An API client for docker written in Python

API

docker.Client(base_url='unix://var/run/docker.sock', version="1.3")
Client class. base_url refers to the protocol+hostname+port where the docker server is hosted. Version is the version of the API the client will use.

  • c.build(path=None, tag=None, quiet=False, fileobj=None)
    Similar to the docker build command. Either path or fileobj needs to be set. path can be a local path (to a directory containing a Dockerfile) or a remote URL. fileobj must be a readable file-like object to a Dockerfile.

  • c.commit(container, repository=None, tag=None, message=None, author=None, conf=None)
    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)
    Creates a container that can then be started. Parameters are similar to those for the docker run command except it doesn't support the attach options (-a)

  • c.diff(container)
    Identical to the docker diff command.

  • c.export(container)
    Identical to the docker export command.

  • c.history(image)
    Identical to the docker history command.

  • c.images(name=None, quiet=False, all=False, viz=False)
    Identical to the docker images command.

  • c.import_image(src, repository=None, tag=None)
    Identical to the docker import command. If src is a string or unicode string, it will be treated as a URL to fetch the image from. To import an image from the local machine, src needs to be a file-like object or bytes collection.

  • c.info()
    Identical to the docker info command.

  • c.insert(url, path)
    Identical to the docker insert command.

  • c.inspect_container(container_id)
    Identical to the docker inspect command, but can only be used with a container ID.

  • c.inspect_image(container_id)
    Identical to the docker inspect command, but can only be used with an image ID.

  • c.kill(containers...)
    Identical to the docker kill command.

  • c.login(username, password=None, email=None)
    Identical to the docker login command (but non-interactive, obviously).

  • c.logs(container)
    Identical to the docker logs command.

  • c.port(container, private_port)
    Identical to the docker port command.

  • c.pull(repository, tag=None, registry=None)
    Identical to the docker pull command.

  • c.push(repository)
    Identical to the docker push command.

  • c.remove_container(containers..., v=False)
    Identical to the docker rm command.

  • c.remove_image(images...)
    Identical to the docker rmi command.

  • c.restart(containers..., t=10)
    Identical to the docker restart command.

  • c.search(term)
    Identical to the docker search command.

  • c.start(container)
    Identical to the docker start command, but doesn't support attach options. Use docker logs to recover stdout/stderr

  • c.start(container, binds={'/host': '/mnt'})
    Allows to bind a directory in the host to the container. Similar to the docker run command with the -b="/host:/mnt". Requires the container to be created with the volumes argument: c.create_container(..., volumes={'/mnt': {}})

  • c.stop(containers..., t=10)
    Identical to the docker stop command.

  • c.tag(image, repository, tag=None, force=False)
    Identical to the docker tag command.

  • c.version()
    Identical to the docker version command.

  • c.wait(containers...)
    Identical to the docker wait command.