charms.docker package


charms.docker.compose module

charms.docker.docker module

class charms.docker.docker.Docker(socket='unix:///var/run/docker.sock', workspace=None)

Bases: object

Wrapper class to communicate with the Docker daemon on behalf of a charmer. Provides stateless operations of a running docker daemon

healthcheck(container_id, verbose=False)

Check the health status of a container. Read more about the HEALTHCHECK Docker instruction:

  • container_id – The container identifier to healthcheck.
  • verbose – Get more detailed healthcheck information.

Returns True if the current healthcheck status is healthy, else False. If verbose is specified a dictionary is returned with details about the healthcheck command, None if no healthcheck exist.

inspect(container_id, inspect_format=None)

Kill a running container

login(user, password, email, registry=None)

Docker login exposed as a method.

  • user – Username in the registry
  • password
    • Password for the registry
  • email
    • Email address on account (dockerhub)

Docker logs exposed as a method.

  • UUID for the container to fetch logs

Pedantically kill a container, by killing it, then wait, then docker rm -f -v the container.


Return a string of docker status output.


Pull an image from the docker hub

rm(container_id, force=False, volume=False)

Remove the container.

  • container_id – The container identifier to remove.
  • force – Force the removal of a running container (uses SIGKILL).
  • volume – Remove the volumes associated with the container.
run(image, options=[], commands=[], arg=[])

Docker Run exposed as a method. This wont be as natural as the command line docker experience.

Docker CLI output example: Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

  • image – string of the container to pull from the registry, eg: ubuntu:latest
  • options – array of string options, eg: [‘-d’, ‘-v /tmp:/tmp’]
  • commands – array of string commands, eg: [‘ls’]
  • arg – array of string command args, eg: [‘-al’]

Predicate method to determine if the daemon we are talking to is actually online and recieving events.

ex: bootstrap = Docker(socket=”unix:///var/run/docker-bootstrap.sock”) bootstrap.running() > True


Block until a container has successfully stopped, and returns the exit code

charms.docker.dockeropts module

charms.docker.workspace module

class charms.docker.workspace.Workspace(path, context='compose')

Bases: object

Docker workspaces are unique in our world, as they can be one of two context dependent things: A Docker build directory, containing only a single Dockerfile, or they can be part of a formation using docker-compose in which they warehouse a docker-compose.yml file.

Under most situations we only care about the context the charm author wishes to be in, and what implications that has on the workspace to be valid.

This method simply exposes an overrideable object to determine these characteristics.


Module contents