pyinfra.connectors.docker module

The @docker connector allows you to build Docker images, or modify running Docker containers, using pyinfra. You can pass either an image name or existing container ID:

  • Image - will create a container from the image, execute operations and save
    into a new image
  • Existing container ID - will simply execute operations against the container,
    leaving it up afterwards
# A Docker base image must be provided
pyinfra @docker/alpine:3.8 ...

# pyinfra can run on multiple Docker images in parallel
pyinfra @docker/alpine:3.8,@docker/ubuntu:bionic ...

# Execute against a running container
pyinfra @docker/2beb8c15a1b1 ...
class pyinfra.connectors.docker.Meta

Bases: pyinfra.api.connectors.BaseConnectorMeta

class DataKeys

Bases: object

container_id = 'ID of container to target, overrides ``docker_identifier``'
identifier = 'ID of container or image to target'
handles_execution = True
keys_prefix = 'docker'
pyinfra.connectors.docker.connect(state, host)
pyinfra.connectors.docker.disconnect(state, host)
pyinfra.connectors.docker.get_file(state, host, remote_filename, filename_or_io, remote_temp_filename=None, print_output=False, print_input=False, **kwargs)

Download a file from the target Docker container by copying it to a temporary location and then reading that into our final file/IO object.

pyinfra.connectors.docker.make_names_data(identifier=None)
pyinfra.connectors.docker.put_file(state, host, filename_or_io, remote_filename, remote_temp_filename=None, print_output=False, print_input=False, **kwargs)

Upload a file/IO object to the target Docker container by copying it to a temporary location and then uploading it into the container using docker cp.

pyinfra.connectors.docker.run_shell_command(state, host, command, get_pty=False, timeout=None, stdin=None, success_exit_codes=None, print_output=False, print_input=False, return_combined_output=False, **command_kwargs)