Communicating with Docker

DockerDaemon

The DockerDaemon object allows us to communicate with the Docker daemon via the Docker HTTP REST API.

exception subuserlib.classes.docker.dockerDaemon.ContainerDependsOnImageException[source]
exception subuserlib.classes.docker.dockerDaemon.ImageBuildException[source]
exception subuserlib.classes.docker.dockerDaemon.ImageDoesNotExistsException[source]
subuserlib.classes.docker.dockerDaemon.RealDockerDaemon

alias of DockerDaemon

exception subuserlib.classes.docker.dockerDaemon.ServerErrorException[source]
subuserlib.classes.docker.dockerDaemon.archiveBuildContext(archive, relativeBuildContextPath, repositoryFileStructure, excludePatterns, dockerfile=None)[source]

Archive files from directoryWithDockerfile into the FileObject archive excluding files who’s paths(relative to directoryWithDockerfile) are in excludePatterns. If dockerfile is set to a string, include that string as the file Dockerfile in the archive.

subuserlib.classes.docker.dockerDaemon.readAndPrintStreamingBuildStatus(user, response)[source]

Container

Container objects allow you to interact with docker containers via the Docker daemon.

class subuserlib.classes.docker.container.Container(user, containerId)[source]
getId()[source]
inspect()[source]

Returns a dictionary of container properties. If the container no longer exists, return None.

remove(force=False)[source]
stop()[source]

Helper functions

This module helps us interact with the Docker executable directly.

subuserlib.docker.buildImageTag(tag, hash)[source]
subuserlib.docker.getAndVerifyExecutable()[source]

Return the name of the docker executable. Exits and displays a user friendly error message if docker is not setup correctly.

subuserlib.docker.getExecutable()[source]

Return the name of the docker executable or None if docker is not installed.

subuserlib.docker.run(args, cwd=None)[source]

Run docker with the given command line arguments. Return Docker’s exit code.

subuserlib.docker.runBackground(args, cwd=None, suppressOutput=True, collectStdout=False, collectStderr=False)[source]

Run docker with the given command line arguments. Return Docker’s pid.