charms.docker package¶
Submodules¶
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: https://docs.docker.com/engine/reference/builder/#/healthcheck
Parameters: - container_id – The container identifier to healthcheck.
- verbose – Get more detailed healthcheck information.
Returns: 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
(container_id)¶ Kill a running container
-
load
(path)¶
-
login
(user, password, email, registry=None)¶ Docker login exposed as a method.
Parameters: - user – Username in the registry
- password –
- Password for the registry
- email –
- Email address on account (dockerhub)
-
logs
(container_id)¶ Docker logs exposed as a method.
Parameters: container_id – - UUID for the container to fetch logs
-
pedantic_kill
(container_id)¶ Pedantically kill a container, by killing it, then wait, then docker rm -f -v the container.
-
ps
()¶ Return a string of docker status output.
-
pull
(image)¶ Pull an image from the docker hub
-
rm
(container_id, force=False, volume=False)¶ Remove the container.
Parameters: - 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...]
Parameters: - 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’]
-
running
()¶ 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
-
wait
(container_id)¶ 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.
-
validate
()¶
-