Docker Container Driver Documentation¶
Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.

Instantiating the driver¶
from libcloud.container.types import Provider
from libcloud.container.providers import get_driver
cls = get_driver(Provider.DOCKER)
conn = cls(host="https://198.61.239.128", port=4243, key_file="key.pem", cert_file="cert.pem")
conn.list_images()
API Docs¶
- class libcloud.container.drivers.docker.DockerContainerDriver(key='', secret='', secure=False, host='localhost', port=4243, key_file=None, cert_file=None)[source]¶
Docker container driver class.
>>> from libcloud.container.providers import get_driver >>> driver = get_driver('docker') >>> conn = driver(host='198.61.239.128', port=4243) >>> conn.list_containers() or connecting to http basic auth protected https host: >>> conn = driver('user', 'pass', host='https://198.61.239.128', port=443)
connect with tls authentication, by providing a hostname, port, a private key file (.pem) and certificate (.pem) file >>> conn = driver(host=’https://198.61.239.128’, >>> port=4243, key_file=’key.pem’, cert_file=’cert.pem’)
- Parameters:
key (
str
) – API key or username to used (required)secret (
str
) – Secret password to be used (required)secure (
bool
) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.host (
str
) – Override hostname used for connections.port (
int
) – Override port used for connections.key_file (
str
) – Path to private key for TLS connection (optional)cert_file (
str
) – Path to public key for TLS connection (optional)
- Returns:
None
- connectionCls¶
alias of
DockerConnection
- create_cluster(name: str, location: ClusterLocation | None = None) ContainerCluster ¶
Create a container cluster
- Parameters:
name (
str
) – The name of the clusterlocation (
ClusterLocation
) – The location to create the cluster in
- Return type:
- deploy_container(name, image, parameters=None, start=True, command=None, hostname=None, user='', stdin_open=True, tty=True, mem_limit=0, ports=None, environment=None, dns=None, volumes=None, volumes_from=None, network_disabled=False, entrypoint=None, cpu_shares=None, working_dir='', domainname=None, memswap_limit=0, port_bindings=None, network_mode='bridge', labels=None)[source]¶
Deploy an installed container image
For details on the additional parameters see : http://bit.ly/1PjMVKV
- Parameters:
name (
str
) – The name of the new containerimage (
libcloud.container.base.ContainerImage
) – The container image to deployparameters (
str
) – Container Image parametersstart (
bool
) – Start the container on deployment
- Return type:
Container
- destroy_cluster(cluster: ContainerCluster) bool ¶
Delete a cluster
- Returns:
True
if the destroy was successful, otherwiseFalse
.- Return type:
bool
- destroy_container(container)[source]¶
Remove a container
- Parameters:
container (
libcloud.container.base.Container
) – The container to be destroyed- Returns:
True if the destroy was successful, False otherwise.
- Return type:
bool
- ex_delete_image(image)[source]¶
Remove image from the filesystem
- Parameters:
image (
libcloud.container.base.ContainerImage
) – The image to remove- Return type:
bool
- ex_get_logs(container, stream=False)[source]¶
Get container logs
If stream == True, logs will be yielded as a stream From Api Version 1.11 and above we need a GET request to get the logs Logs are in different format of those of Version 1.10 and below
- Parameters:
container (
libcloud.container.base.Container
) – The container to list logs forstream (
bool
) – Stream the output
- Return type:
bool
- ex_list_processes(container)[source]¶
List processes running inside a container
- Parameters:
container (
libcloud.container.base.Container
) – The container to list processes for.- Return type:
str
- ex_rename_container(container, name)[source]¶
Rename a container
- Parameters:
container (
libcloud.container.base.Container
) – The container to be renamedname (
str
) – The new name
- Return type:
- ex_search_images(term)[source]¶
Search for an image on Docker.io. Returns a list of ContainerImage objects
>>> images = conn.ex_search_images(term='mistio') >>> images [<ContainerImage: id=rolikeusch/docker-mistio...>, <ContainerImage: id=mist/mistio, name=mist/mistio, driver=Docker ...>]
- param term:
The search term
- type term:
str
- rtype:
- get_cluster(id: str) ContainerCluster ¶
Get a cluster by ID
- Parameters:
id (
str
) – The ID of the cluster to get- Return type:
- get_container(id)[source]¶
Get a container by ID
- Parameters:
id (
str
) – The ID of the container to get- Return type:
- install_image(path)[source]¶
Install a container image from a remote path.
- Parameters:
path (
str
) – Path to the container image- Return type:
- list_clusters(location: ClusterLocation | None = None) List[ContainerCluster] ¶
Get a list of potential locations to deploy clusters into
- Parameters:
location (
ClusterLocation
) – The location to search in- Return type:
list
ofContainerCluster
- list_containers(image=None, all=True)[source]¶
List the deployed container images
- Parameters:
image (
libcloud.container.base.ContainerImage
) – Filter to containers with a certain imageall (
bool
) – Show all container (including stopped ones)
- Return type:
- list_locations() List[ClusterLocation] ¶
Get a list of potential locations to deploy clusters into
- Return type:
list
ofClusterLocation
- restart_container(container)[source]¶
Restart a container
- Parameters:
container (
libcloud.container.base.Container
) – The container to be stopped- Returns:
The container refreshed with current data
- Return type:
- start_container(container)[source]¶
Start a container
- Parameters:
container (
libcloud.container.base.Container
) – The container to be started- Returns:
The container refreshed with current data
- Return type:
- stop_container(container)[source]¶
Stop a container
- Parameters:
container (
libcloud.container.base.Container
) – The container to be stopped- Returns:
The container refreshed with current data
- Return type:
- supports_clusters = False¶
Whether the driver supports containers being deployed into clusters