Container API is available in Libcloud 1.0.0-pre1 and higher.
Container API is currently in an EXPERIMENTAL state.
Container API allows users to install and deploy containers onto container based virtualization platforms. This is designed to target both on-premise installations of software like Docker as well as interfacing with Cloud Service Providers that offer Container-as-a-Service APIs.
For a working example of the container driver with cluster support, see the example for Amazon’s Elastic Container Service:
from libcloud.container.base import ContainerImage from libcloud.container.types import Provider from libcloud.container.providers import get_driver cls = get_driver(Provider.ECS) conn = cls( access_id="SDHFISJDIFJSIDFJ", secret="THIS_IS)+_MY_SECRET_KEY+I6TVkv68o4H", region="ap-southeast-2", ) for cluster in conn.list_clusters(): print(cluster.name) if cluster.name == "default": container = conn.deploy_container( cluster=cluster, name="my-simple-app", image=ContainerImage( id=None, name="simple-app", path="simple-app", version=None, driver=conn ), )
For an example of the simple container support, see the Docker example:
from libcloud.container.types import Provider from libcloud.container.providers import get_driver cls = get_driver(Provider.DOCKER) driver = cls(host="https://126.96.36.199", port=4243, key_file="key.pem", cert_file="cert.pem") image = driver.install_image("tomcat:8.0") container = driver.deploy_container("tomcat", image)
Container-as-a-Service providers will implement the ContainerDriver class to provide functionality for :
Listing deployed containers
Starting, stopping and restarting containers (where supported)
Listing container images
Installing container images (pulling an image from a local copy or remote repository)
Driver base API documentation is found here:
ContainerDriver- A driver for interfacing to a container provider
Simple Container Support¶
Cluster support extends on the basic driver functions, but where drivers implement the class-level attribute supports_clusters as True clusters may be listed, created and destroyed. When containers are deployed, the target cluster can be specified.
Bootstrapping Docker with Compute Drivers¶
The compute and container drivers can be combined using the deployment feature of the compute driver to bootstrap an installation of a container virtualization provider like Docker. Then using the Container driver, you can connect to that API and install images and deploy containers.
For a list of supported providers see supported providers page.
We have examples of several common patterns.
For a full reference of all the classes and methods exposed by the Container API, see this page.
There are some utility classes for example, a Docker Hub API client for fetching images and iterating through repositories see this page.