pawnlib.docker package

from pawnlib.docker import *

Submodules

pawnlib.docker.async_docker module

from pawnlib.docker import async_docker
class AsyncDocker(client=None, filters={}, client_options={}, max_at_once=10, max_per_second=10, container_name='', count=0)[source]

Bases: object

async close()[source]
run_async_loop(function)[source]
client_decorator()[source]
pull_image(*args, **kwargs)[source]
get_images(*args, **kwargs)[source]
find_image(image=None)[source]
filtering_dict(item, filters=None)[source]
get_containers(*args, **kwargs)[source]
parse_container_dict(container)[source]
async delete_container(container, container_total, count)[source]
control_container(method=None, *args, **kwargs)[source]
async delete_container(container, container_total=0, count=0)[source]
async list_things(args, filters={})[source]
async rm_container(args)[source]
async run_container(numbering, *args, **kwargs)[source]
async run_dyn_container(config, *args, **kwargs)[source]
extract_upper_key_to_env_list(config=None)[source]

pawnlib.docker.compose module

from pawnlib.docker import compose
class DockerComposeBuilder(compose_file='docker-compose.yml')[source]

Bases: object

A class to build and manage Docker Compose files interactively.

Parameters:

compose_file (optional) – Name of the Docker Compose file to be created or modified (default: “docker-compose.yml”). |default| 'docker-compose.yml'

Example

dcb = DockerComposeBuilder()

dcb.create_docker_compose()
# Starts an interactive session to create a Docker Compose file.

dcb.save_docker_compose()
# Saves the created Docker Compose data to a file.

data = dcb.get_docker_compose_data()
# Returns the Docker Compose data as a dictionary.

dcb.remove_service()
# Removes a service from the Docker Compose configuration.
create_docker_compose()[source]
confirm_with_min_once(message, already_asked)[source]

Set the default value to ‘yes’ at least once, and then set it to ‘no’ afterwards.

confirm_with_default(message, default=True)[source]

Default confirm question logic

get_valid_input(message, default=None)[source]

Get valid non-empty input from the user, validate the input.

get_ports()[source]

Get port mappings from the user.

is_valid_port_mapping(port)[source]

Validate port mapping format (e.g., 8080:80)

get_environment_variables()[source]

Get environment variables from the user.

get_volumes(default_volume='./data:/data')[source]

Get volume mappings from the user and validate the format.

is_valid_volume_mapping(volume)[source]

Validate volume mapping format (e.g., ./data:/app/data)

validate_docker_image(image)[source]

Validate if the Docker image exists locally or in Docker Hub

is_image_in_local(image)[source]

Check if the Docker image exists locally using docker images command

is_image_in_docker_hub(image)[source]

Validate if the Docker image exists in Docker Hub

add_service(service_name='', service={})[source]
get_docker_compose_data()[source]

Return the YAML data for Docker Compose.

remove_service()[source]

Remove a service from the services list.

save_docker_compose()[source]

Save the Docker Compose data to a file, with confirmation.