XD Docker Documentation¶
Docker Remote API Python library.
Contents¶
Introduction¶
XD Docker is a Python library for accessing services providing a Docker Remote API compatible interface (ie. Docker Engine and Docker Swarm), built on top of the Requests library.
The primary goal of XD Docker is to provide a stable, easy-to-use and Pythonic API for writing applications that use Docker Remote API. When this is achieved, more advanced features might be added on top of it.
XD Docker is compatible with Python 3.4 and newer, and Docker Remote API version 1.14 and newer. Support for older Python versions should be possible (patches are welcome). Support for older Docker Remote API versions should also be possible, but the current integration test cannot supported these due to Docker HUB not supporting older clients, so official support in XD Docker is not likely.
Installation¶
The latest release can be installed using the following command:
pip install xd-docker
Dependencies¶
The following libraries will be automatically installed from PyPI together with XD Docker:
- requests
- requests-unixsocket
- typing
Docker service¶
In order to use XD Docker, you need to have access to a service providing Docker Remote API, either a Docker Engine or Docker Swarm service. It needs to be accessible either through a Unix or TCP socket.
First steps¶
API¶
xd.docker package¶
xd.docker.client module¶
Module containing DockerClient and associated exceptions.
-
class
xd.docker.client.
DockerClient
(host=None)[source]¶ Bases:
object
Docker client.
A DockerClient instance is used to communicate with Docker daemon (or something else that is speaking Docker Remote API).
Parameters: host ( Optional
[str
]) – URL to Docker daemon socket to connect to.Example: Connect to docker daemon on localhost TCP socket:
>>> docker = DockerClient('tcp://127.0.0.1:2375')
Connect to docker daemon on UNIX domain socket:
>>> docker = DockerClient('unix:///var/run/docker.sock')
-
version
()[source]¶ Get Docker Remote API version.
Raises: ServerError
– Server error.Return type: Tuple
[int
,int
]Returns: Major/minor version number of Docker daemon (Docker Remote API).
-
containers
(only_running=True)[source]¶ Get list of containers.
By default, only running containers are returned.
Keyword Arguments: only_running – List only running containers (if True), or all containers (if False).
Raises: ClientError
– Bad parameter.ServerError
– Server error.
Return type: List
Returns: List of containers.
-
images
()[source]¶ Get list of images.
Images returned does only contain partial information. To obtain detailed information, use
image_inspect
orImage.inspect
on theImage
in question.Raises: ServerError
– Server error.Return type: List
Returns: List of images.
-
image_inspect
(name)[source]¶ Get image with low-level information.
Get low-level information of a named image. Returns
Image
instance with the information.Parameters: name ( str
) – name of image.Return type: Image
-
image_build
(context, output=('error', 'stream', 'status'), dockerfile=None, tag=None, cache=True, pull=None, rm=None, force_rm=None, host_config=None, registry_config=None, buildargs=None)[source]¶ Build an image from a Dockerfile.
Build image from a given context or stand-alone Dockerfile.
Parameters: - context (
str
) – path to directory containing build context, or path to a stand-alone Dockerfile. - output – tuple/list of with type of output information to allow (Default: (‘stream’, ‘status’, ‘error’)).
- dockerfile (
Optional
[str
]) – path to dockerfile in build context. - tag (
Union
[Repository
,str
,None
]) – repository name and tag to be applied to the resulting image. - cache (
bool
) – use the cache when building the image (default: True). - pull (
Optional
[bool
]) – attempt to pull the image even if an older image exists locally (default: False). - rm (
Optional
[bool
]) – False/True. Remove intermediate containers after a successful build (default: True). - force_rm (
Optional
[bool
]) – False/True. Always remove intermediate containers after build (default: False). - host_config (
Optional
[HostConfig
]) – HostConfig instance. - registry_config (
Optional
[RegistryAuthConfig
]) – RegistryAuthConfig instance. - buildargs (
Optional
[Dict
]) – build-time environment variables.
- context (
-
image_pull
(name, registry_auth=None, output=('error', 'stream', 'status'))[source]¶ Pull image.
Create an image by pulling it from a registry.
Parameters: - name – name of the image to pull.
- output – tuple/list of with type of output information to allow (Default: (‘stream’, ‘status’, ‘error’)).
-
image_remove
(name)[source]¶ Remove an image.
Remove the image name from the filesystem.
Parameters: name – name of the image to remove.
-
image_tag
(image, tag=None, force=None)[source]¶ Tag an image.
Add tag to an existing image.
Parameters: - image – image to add tag to.
- tag (
Union
[Repository
,str
,None
]) – repository name and optionally tag. - force (
Optional
[bool
]) – force creation of tag.
-
container_create
(config, name=None, mounts=None, host_config=None, pull=True)[source]¶ Create a new container.
Create a new container based on existing image.
Parameters: - config (
ContainerConfig
) – ContainerConfig instance. - name (
Union
[ContainerName
,str
,None
]) – name to assign to container. - mounts (
Optional
[Sequence
]) – mount points in the container (list of strings). - host_config (
Optional
[HostConfig
]) – HostConfig instance. - pull (
bool
) – Pull image if needed.
- config (
-
container_remove
(container, force=None, volumes=None)[source]¶ Remove a container.
Remove a container and (optionally) the associated volumes.
Parameters: - container (
Union
[Container
,ContainerName
,str
]) – The container to remove (id or name). - force (
Optional
[bool
]) – Kill then remove the container. - volumes (
Optional
[bool
]) – Remove the volumes associated to the container.
- container (
-
container_start
(container)[source]¶ Start a container.
Parameters: container ( Union
[Container
,ContainerName
,str
]) – The container to start (id or name).Returns: True if container was started. False if container was already started.
-
container_wait
(container)[source]¶ Block until container stops.
Block until container stops, then returns the exit code.
Parameters: container ( Union
[Container
,ContainerName
,str
]) – The container to remove (id or name).Return type: int
Returns: Container exit code.
-
container_stop
(container, timeout=None)[source]¶ Stop container.
Stop the container, and optionally killing the container after a timeout.
Parameters: - container (
Union
[Container
,ContainerName
,str
]) – The container to remove (id or name). - timeout (
Optional
[int
]) – Number of seconds to wait before killing the container.
Returns: True if container was stopped. False if container was already stopped.
- container (
-
container_restart
(container, timeout=None)[source]¶ Restart container.
Restart the container, and optionally killing the container after a timeout waiting for the container to stop.
Parameters: - container (
Union
[Container
,ContainerName
,str
]) – The container to remove (id or name). - timeout (
Optional
[int
]) – Number of seconds to wait before killing the container.
- container (
-
container_kill
(container, signal=None)[source]¶ Kill container.
Send signal to container, and (maybe) wait for the container to exit.
Note: Prior to Docker version 1.8, kill succeeds (without actually doing anything) when run on existing but stopped containers. Docker 1.8 and newer fails out with a ServerError exception.
Parameters: - container (
Union
[Container
,ContainerName
,str
]) – The container to remove (id or name). - signal (
Union
[int
,str
,None
]) – Signal to send to container.
- container (
-
xd.docker.container module¶
xd.docker.datetime module¶
xd.docker.image module¶
xd.docker.parameters module¶
Module containing helper classes and functions for handling Docker Remote API parameters.
-
xd.docker.parameters.
ApiVersion
¶ alias of
Tuple
-
xd.docker.parameters.
json_update
(obj, values, json_fields, api_version=None)[source]¶ Update JSON object (dict).
This function is used to update a JSON object (a dict) with name/value pairs from the values argument, based on the specification in json_fields and api_version arguments.
Parameters: - obj (
Dict
) – JSON object to update. - values (
Dict
) – Name/value pairs to update with. - json_fields (
Sequence
) – Specification of supported JSON object name/value pairs, including information on which API version they are supported in. - api_version (
Optional
[Tuple
[int
,int
]]) – API version to update for.
- obj (
-
class
xd.docker.parameters.
Parameter
[source]¶ Bases:
object
Base class for all XD Docker parameter classes.
-
class
xd.docker.parameters.
Hostname
(hostname)[source]¶ Bases:
xd.docker.parameters.Parameter
Hostname.
A Hostname instance represents a network hostname. A hostname must not contain dots (‘.’). To specify a fully qualified domain name, use
Domainname
.Parameters: hostname ( str
) – Hostname.-
hostname
¶ str – Hostname.
-
-
class
xd.docker.parameters.
Domainname
(domainname)[source]¶ Bases:
xd.docker.parameters.Hostname
Domain name.
A Domainname instance represents a network domain name.
Parameters: domainname ( str
) – Domain name.-
domainname
¶ str – Domain name.
-
-
class
xd.docker.parameters.
MacAddress
(addr)[source]¶ Bases:
xd.docker.parameters.Parameter
Ethernet MAC address.
A MacAddress instance represents an Ethernet MAC address.
Parameters: addr ( str
) – MAC address (fx. ‘01:02:03:04:05:06’).-
addr
¶ str – MAC address (fx. ‘01:02:03:04:05:06’).
-
-
class
xd.docker.parameters.
Username
(username)[source]¶ Bases:
xd.docker.parameters.Parameter
User name.
A Username instance represents a UNIX user name.
Parameters: username ( str
) – User name.-
username
¶ str – User name.
-
-
class
xd.docker.parameters.
Repository
(repo)[source]¶ Bases:
xd.docker.parameters.Parameter
Repository name (and optionally tag) parameter.
A Repository instance is used to represent a Docker repository name, or repository name and tag.
Parameters: repo ( str
) – Repository name, or name and tag (separated by ‘:’).-
name
¶ str – Repository name.
-
tag
¶ Optional[str] – Repository tag.
-
-
class
xd.docker.parameters.
RepoTags
(repos)[source]¶ Bases:
xd.docker.parameters.Parameter
List of repository name and tags.
A RepoTags instance is used to represent a list of repository name and tags.
Parameters: repos ( List
) – List of repository name and tags (separated by ‘:’).-
repos
¶ List[Repository] – List of repository name and tags.
-
-
class
xd.docker.parameters.
ContainerName
(name)[source]¶ Bases:
xd.docker.parameters.Parameter
Container name parameter.
A ContainerName instance is used to represent a Docker container name.
Parameters: name ( str
) – Container name-
name
¶ str – Container name.
-
-
class
xd.docker.parameters.
Env
(env=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Environment variables.
An Environment instance contains the environment variables for a Docker container.
Parameters: env ( Optional
[Mapping
]) – Environment variables, name/value pairs.-
env
¶ Mapping[str, str] – Environment variables, name/value pairs.
-
-
class
xd.docker.parameters.
Port
(port, protocol='tcp')[source]¶ Bases:
xd.docker.parameters.Parameter
Network port.
A Port instance represents a network port (TCP or UDP).
Parameters: - port (
int
) – Port number. - protocol (
str
) – Protocol (‘tcp’ or ‘udp’).
-
port
¶ int – Port number.
-
protocol
¶ str – Protocol (‘tcp’ or ‘udp’).
- port (
-
class
xd.docker.parameters.
PortBinding
(port, protocol='tcp', host_ip=None, host_port=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Docker container port binding.
A PortBinding instance represents a binding of a network port of a Docker container to a host port.
Parameters: - port (
int
) – Container port number. - protocol (
str
) – Protocol (‘tcp’ or ‘udp’). - host_ip (
Union
[IPv4Address
,IPv6Address
,None
]) – Host IP address. - host_port (
Optional
[int
]) – Host port number (defaults to container port number).
-
port
¶ int – Container port number (1 ... 65535).
-
protocol
¶ str – Protocol (‘tcp’ or ‘udp’).
-
host_ip
¶ Optional[IPAddress] – Host IP address.
-
host_port
¶ int – Host port number (1 ... 65535).
- port (
-
class
xd.docker.parameters.
VolumeMount
(source, destination, ro=False, label_mode=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Volume mount point.
A VolumeMount instance represents a container mount point.
Parameters: - source (
str
) – Host path. - destination (
str
) – Container path. - ro (
bool
) – Read-only mount. - label_mode (
Optional
[str
]) – SELinux label mode (‘z’ or ‘Z’).
-
source
¶ str – Source path.
-
destination
¶ str – Destination path.
-
ro
¶ bool – Read-only mount.
-
label_mode
¶ str – SELinux label mode (‘’, ‘z’, or ‘Z’).
- source (
-
class
xd.docker.parameters.
VolumeBinding
(container_path, volume=None, ro=False)[source]¶ Bases:
xd.docker.parameters.Parameter
Volume binding.
A VolumeBinding instance represents a volume binding for a container. The binding can either be to a new volume, an existing host path, or a volume provided by a Docker volume plugin.
Parameters: - container_path (
str
) – Container path to bind the volume to. - volume (
Optional
[str
]) – Host path or volume name, identifying the volume to bind to. Host path must start with a ‘/’. Volume name must not begin with a ‘/’. - ro (
bool
) – Read-only mount.
-
container_path
¶ str – Container path to bind the volume to.
-
volume
¶ Optional[str] – Host path or volume name, identifying the volume to bind to.
-
ro
¶ bool – Read-only mount.
- container_path (
-
class
xd.docker.parameters.
ContainerLink
(name, alias)[source]¶ Bases:
xd.docker.parameters.Parameter
Container link.
A ContainerLink instance represents a link to another container.
Parameters: - name (
str
) – Name of container to link to. - alias (
str
) – Alias to use for linked container.
-
name
¶ str – Name of container to link to.
-
alias
¶ str – Alias to use for linked container.
- name (
-
class
xd.docker.parameters.
Cpuset
(cpuset)[source]¶ Bases:
xd.docker.parameters.Parameter
List of CPUs.
A Cpuset instance represents a set of CPU or memory nodes, for use when specifying where to run a container.
Parameters: cpuset ( str
) – Cpuset specification. See cpuset(7) for syntax.-
cpuset
¶ str – Cpuset specification.
-
-
class
xd.docker.parameters.
HostnameIPMapping
(hostname, ip)[source]¶ Bases:
xd.docker.parameters.Parameter
Hostname to IP address mapping.
A HostnameIPMapping instance represents a mapping from a hostname to an IP address (IPv6 or IPv4).
Parameters: - hostname (
Union
[Hostname
,str
]) – Hostname. - ip (
Union
[IPv4Address
,IPv6Address
,str
]) – IP address.
-
hostname
¶ Hostname – Hostname.
-
ip
¶ IPAddress – IP address.
- hostname (
-
class
xd.docker.parameters.
VolumesFrom
(name, ro=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Docker container to inherit volumes from.
A VolumesFrom instance represents a single docker container to inherit volumes from.
Parameters: - name (
Union
[ContainerName
,str
]) – Container name. - ro (
Optional
[bool
]) – Mount volumes read-only (default is read/write).
-
name
¶ ContainerName – Container name.
-
ro
¶ Optional[bool] – Mount volumes read-only.
- name (
-
class
xd.docker.parameters.
RestartPolicy
(policy, maximum_retry_count=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Restart policy for when the container exits.
A RestartPolicy instance represents the restart policy to use when container exits.
Parameters: - policy (
str
) – One of ‘always’, ‘unless-stopped’, or ‘on-failure. - maximum_retry_count (
Optional
[int
]) – Number of times to retry before giving up (required and only allowed together with ‘on-failure’)
-
policy
¶ str – One of ‘always’, ‘unless-stopped’, or ‘on-failure’.
-
maximum_retry_count
¶ int – Number of times to retry before giving up (only present when policy is ‘on-failure’).
- policy (
-
class
xd.docker.parameters.
DeviceToAdd
(path_on_host, path_in_container=None, cgroup_permissions='rwm')[source]¶ Bases:
xd.docker.parameters.Parameter
Device to add to container.
A DeviceToAdd instance represents a device to add to a container.
Parameters: - path_on_host (
str
) – Device path on host. - path_in_container (
Optional
[str
]) – Device path in container (defaults to path_on_host). - cgroup_permissions (
str
) – Access permission, composition of ‘r’ (read), ‘w’ (write), and ‘m’ (mknod) (defaults to ‘rwm’).
-
path_on_host
¶ str – Device path on host.
-
path_in_container
¶ str – Device path in container.
-
cgroup_permissions
¶ str – Access permission, composition of ‘r’ (read), ‘w’ (write), and ‘m’ (mknod).
- path_on_host (
-
class
xd.docker.parameters.
Ulimit
(name, soft, hard=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Ulimit parameter.
A Ulimit instance represents a ulimit (user limit) to set in a container.
Parameters: - name (
str
) – Name of ulimit. - soft (
int
) – Soft limit. - hard (
Optional
[int
]) – Hard limit (defaults to soft limit).
-
name
¶ str – Name of ulimit.
-
soft
¶ str – Soft limit.
-
hard
¶ str – Hard limit.
- name (
-
class
xd.docker.parameters.
LogConfiguration
(type, config=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Log configuration for container.
A LogConfiguration instance represents configuration of how logging is done for a container.
Parameters: - type (
str
) – Logging driver name. - config (
Optional
[Mapping
]) – Driver specific configuration parameters.
-
type
¶ str – Logging driver name.
-
config
¶ Dict[str, str] – Driver specific configuration parameters.
- type (
-
class
xd.docker.parameters.
AuthConfig
[source]¶ Bases:
xd.docker.parameters.Parameter
Login information for a docker registry.
An AuthConfig instance represents login information for authenticating to a docker repository.
-
class
xd.docker.parameters.
CredentialAuthConfig
(username, password, email=None)[source]¶ Bases:
xd.docker.parameters.AuthConfig
Credential based login information for a docker registry.
A CredentialAuthConfig instance represents credential based login information for authenticating to a docker repository.
Parameters: - username (
str
) – User name. - password (
str
) – Password. - email (
Optional
[str
]) – Email address.
-
username
¶ str – User name.
-
password
¶ str – Password.
-
email
¶ Optional[str] – Email address.
- username (
-
class
xd.docker.parameters.
TokenAuthConfig
(token)[source]¶ Bases:
xd.docker.parameters.AuthConfig
Token based login information for a docker registry.
A TokenAuthConfig instance represents token based login information for authenticating to a docker repository.
Parameters: token ( str
) – Login token.-
token
¶ str – Login token.
-
-
class
xd.docker.parameters.
RegistryAuthConfig
(registry_auths)[source]¶ Bases:
xd.docker.parameters.Parameter
Docker registry authentication configuration.
A RegistryAuthConfig instance represents the login information for one or more docker registries.
Parameters: registry_auths ( Mapping
) – Mapping of registry hostnames to the login information for authenticating to that registry. Only the registry domain name (and port if not the default “443”) are required. However (for legacy reasons) the “official” Docker, Inc. hosted registry must be specified with both a “https://” prefix and a “/v1/” suffix even though Docker will prefer to use the v2 registry API.-
registry_auths
¶ Mapping of registry hostnames to login information.
-
-
class
xd.docker.parameters.
ContainerConfig
(image, command=None, entrypoint=None, on_build=None, hostname=None, domainname=None, user=None, attach_stdin=None, attach_stdout=None, attach_stderr=None, tty=None, open_stdin=None, stdin_once=None, env=None, labels=None, working_dir=None, network=None, mac_address=None, exposed_ports=None, volumes=None, stop_signal=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Container configuration parameter.
A ContainerConfig instance represents the configuration of a container.
Parameters: - image (
str
) – Image to create container from. - command (
Optional
[Sequence
]) – Command to run. - entrypoint (
Optional
[Sequence
]) – Container entrypoint. - on_build (
Optional
[Sequence
]) – Trigger instructions to be executed later (when used as base image for another build). - hostname (
Union
[Hostname
,str
,None
]) – Hostname to use for the container. - domainname (
Union
[Domainname
,str
,None
]) – Domain name to use for the container. - user (
Union
[Username
,str
,None
]) – User inside the container. - attach_stdin (
Optional
[bool
]) – Attach to stdin. - attach_stdout (
Optional
[bool
]) – Attach to stdout. - attach_stderr (
Optional
[bool
]) – Attach to stderr. - tty (
Optional
[bool
]) – Attach standard streams to a tty. - open_stdin (
Optional
[bool
]) – Open stdin. - stdin_once (
Optional
[bool
]) – Close stdin after the client disconnects. - env (
Union
[Env
,Mapping
,None
]) – Environment variables. - labels (
Optional
[Mapping
]) – Labels to set on container. - working_dir (
Optional
[str
]) – Working directory for command to run in. - network (
Optional
[bool
]) – Whether to enable networking in the container. - mac_address (
Union
[MacAddress
,str
,None
]) – MAC address. - exposed_ports (
Optional
[Sequence
]) – Exposed ports. - volumes (
Optional
[Sequence
]) – List of (in container) paths to use as volumes. - stop_signal (
Union
[int
,str
,None
]) – Signal to stop container.
-
image
¶ str – Image to create container from.
-
command
¶ Optional[Command] – Command to run.
-
entrypoint
¶ Optional[Command] – Container entrypoint.
-
on_build
¶ Optional[Sequence[str]] – Trigger instructions to be executed later (when used as base image for another build).
-
hostname
¶ Optional[Hostname] – Hostname to use for the container.
-
domainname
¶ Optional[Domainname] – Domain name to use for the container.
-
user
¶ Optional[Username] – User inside the container.
-
attach_stdin
¶ Optional[bool] – Attach to stdin.
-
attach_stdout
¶ Optional[bool] – Attach to stdout.
-
attach_stderr
¶ Optional[bool] – Attach to stderr.
-
tty
¶ Optional[bool] – Attach standard streams to a tty.
-
open_stdin
¶ Optional[bool] – Open stdin.
-
stdin_once
¶ Optional[bool] – Close stdin after the client disconnects.
-
env
¶ Optional[Env] – Environment variables.
-
labels
¶ Optional[Mapping[str, str]] – Labels to set on container.
-
working_dir
¶ Optional[str] – Working directory for command to run in.
-
network
¶ Optional[bool] – Whether to enable networking in the container.
-
mac_address
¶ Optional[MacAddress] – MAC address.
-
exposed_ports
¶ Optional[Sequence[Port]] – Exposed ports.
-
volumes
¶ Optional[Sequence[str] – List of (in container) paths to use as volumes.
-
stop_signal
¶ Optional[Union[int, str]] – Signal to stop container.
- image (
-
class
xd.docker.parameters.
HostConfig
(binds=None, links=None, lxc_conf=None, port_bindings=None, publish_all_ports=None, privileged=None, read_only_rootfs=None, dns=None, dns_options=None, dns_search=None, extra_hosts=None, volumes_from=None, cap_add=None, cap_drop=None, group_add=None, restart_policy=None, network_mode=None, devices=None, ulimits=None, security_opt=None, log_config=None, cgroup_parent=None, volume_driver=None, shm_size=None, memory=None, swap=None, memory_reservation=None, kernel_memory=None, cpu_shares=None, cpu_period=None, cpu_quota=None, cpuset_cpus=None, cpuset_mems=None, blkio_weight=None, memory_swappiness=None, oom_kill=None)[source]¶ Bases:
xd.docker.parameters.Parameter
Docker container host configuration.
Parameters: - binds (
Optional
[Sequence
]) – List of volume bindings. - links (
Optional
[Sequence
]) – List of links to other containers. - lxc_config – LXC specific configurations. Only valid when using the lxc execution driver.
- port_bindings (
Optional
[Sequence
]) – List of port bindings, ie. container ports that exposed as host ports. - publish_all_ports (
Optional
[bool
]) – Allocate a random host port for all exposed ports. - privileged (
Optional
[bool
]) – Container has full access to host. - read_only_rootfs (
Optional
[bool
]) – Mount container root filesystem read only. - dns (
Optional
[Sequence
]) – List of DNS servers to use. - dns_options (
Optional
[Sequence
]) – List of DNS options. - dns_search (
Optional
[Sequence
]) – List of DNS search domains. - extra_hosts (
Optional
[Sequence
]) – A list of hostname to IP mappings to add to container’s /etc/hosts file. - volumes_from (
Optional
[Sequence
]) – List of containers to inherit volumes from. - cap_add (
Optional
[Sequence
]) – List of kernel capabilities to add to container. - cap_drop (
Optional
[Sequence
]) – List of kernel capabilities to drop from container. - group_add (
Optional
[Sequence
]) – List of additional groups that the container process will run as. - restart_policy (
Optional
[RestartPolicy
]) – Behavior when container exits. - network_mode (
Optional
[str
]) – Networking mode for the container. - devices (
Optional
[Sequence
]) – List of devices to add to container. - ulimits (
Optional
[Sequence
]) – List of ulimits to set in container. - security_opt (
Optional
[Sequence
]) – List of string values to customize labels for MLS systems, such as SELinux. - log_config (
Optional
[LogConfiguration
]) – Log configuration for container. - cgroup_parent (
Optional
[str
]) – Path to cgroups under which the container’s cgroup is created. - volume_driver (
Optional
[str
]) – Driver that this container uses to mount volumes. - shm_size (
Optional
[int
]) – Size of /dev/shm in bytes. - memory (
Optional
[int
]) – Memory limit in bytes. - swap (
Optional
[int
]) – Swap limit in bytes. - memory_reservation (
Optional
[int
]) – Memory soft limit in bytes. - kernel_memory (
Optional
[int
]) – Kernel memory limit in bytes. - cpu_shares (
Optional
[int
]) – CPU shares relative to other containers. - cpu_period (
Optional
[int
]) – Length of a CPU period in microseconds. - cpu_quota (
Optional
[int
]) – Microseconds of CPU time that the container can get in a CPU period. - cpuset_cpus (
Union
[Cpuset
,str
,None
]) – Cgroups cpuset.cpu to use. - cpuset_mems (
Union
[Cpuset
,str
,None
]) – Cgroups cpuset.mem to use. - blkio_weight (
Optional
[int
]) – Relative block io weight (10 ... 1000). - memory_swappiness (
Optional
[int
]) – Memory swappiness behavior (10 ... 100). - oom_kill (
Optional
[bool
]) – Enable OOM killer for container.
-
binds
¶ Optional[List[VolumeBinding]] – List of volume bindings.
-
links
¶ Optional[List[ContainerLink]] – List of links to other containers.
-
lxc_config
¶ Optional[Dict[str, str]] – LXC specific configurations. Only valid when using the lxc execution driver.
-
port_bindings
¶ Optional[List[PortBinding]] – List of port bindings, ie. container ports that exposed as host ports.
-
publish_all_ports
¶ Optional[bool] – Allocate a random host port for all exposed ports.
-
privileged
¶ Optional[bool] – Container has full access to host.
-
read_only_rootfs
¶ Optional[bool] – Mount container root filesystem read only.
-
dns
¶ Optional[List[IPAddress]] – List of DNS servers to use.
-
dns_options
¶ Optional[List[str]] – List of DNS options.
-
dns_search
¶ Optional[List[str]] – List of DNS search domains.
-
extra_hosts
¶ Optional[List[HostnameIPMapping]] – A list of hostname to IP mappings to add to container’s /etc/hosts file.
-
volumes_from
¶ Optional[List[VolumesFrom]] – List of containers to inherit volumes from.
-
cap_add
¶ Optional[List[str]] – List of kernel capabilities to add to container.
-
cap_drop
¶ Optional[List[str]] – List of kernel capabilities to drop from container.
-
group_add
¶ Optional[List[str]] – List of additional groups that the container process will run as.
-
restart_policy
¶ Optional[RestartPolicy] – Behavior when container exits.
-
network_mode
¶ Optional[str] – Networking mode for the container.
-
devices
¶ Optional[List[DeviceToAdd]] – List of devices to add to container.
-
ulimits
¶ Optional[List[Ulimit]] – List of ulimits to set in container.
-
security_opt
¶ Optional[List[str]] – List of string values to customize labels for MLS systems, such as SELinux.
-
log_config
¶ Optional[LogConfiguration] – Log configuration for container.
-
cgroup_parent
¶ Optional[str] – Path to cgroups under which the container’s cgroup is created.
-
volume_driver
¶ Optional[str] – Driver that this container uses to mount volumes.
-
shm_size
¶ Optional[int] – Size of /dev/shm in bytes.
-
memory
¶ Optional[int] – Memory limit in bytes.
-
swap
¶ Optional[int] – Swap limit in bytes.
-
memory_reservation
¶ Optional[int] – Memory soft limit in bytes.
-
kernel_memory
¶ Optional[int] – Kernel memory limit in bytes.
Optional[int] – CPU shares relative to other containers.
-
cpu_period
¶ Optional[int] – Length of a CPU period in microseconds.
-
cpu_quota
¶ Optional[int] – Microseconds of CPU time that the container can get in a CPU period.
-
cpuset_cpus
¶ Optional[Cpuset] – Cgroups cpuset.cpu to use.
-
cpuset_mems
¶ Optional[Cpuset] – Cgroups cpuset.mem to use.
-
blkio_weight
¶ Optional[int] – Relative block io weight (10 ... 1000).
-
memory_swappiness
¶ Optional[int] – Memory swappiness behavior (10 ... 100).
-
oom_kill
¶ Optional[bool] – Enable OOM killer for container.
- binds (
Developers Guide¶
Change History¶
0.3.0 (in development)¶
- Add container_upload() method.
- Add commit() method.
0.2.0 (2016-08-28)¶
- Add container_remove() method.
- Add container_start() method.
- Add container_wait() method.
- Add container_stop() method.
- Add container_restart() method.
- Add container_kill() method.
- Allow private registry image names.
- Fixed handling of linked containers in containers().
- Support DOCKER_HOST environment variable.
- Add shell script to do manual testing.
0.1.0 (2016-08-13)¶
First development release