simple_docker

API Reference

DOCKER_CLIENT

Main facade for all Docker operations. Communicates with Docker Engine via named pipes.

Creation

make

Create client and connect to Docker daemon.

Postconditions

connection_attempted: True

Connection Queries

FeatureReturn TypeDescription
pingBOOLEANCheck if Docker daemon is responsive
versionSIMPLE_JSON_OBJECTGet Docker version information
infoSIMPLE_JSON_OBJECTGet Docker system information
is_connectedBOOLEANIs client connected to daemon?

Container Operations

FeatureParametersReturnDescription
list_containers a_all: BOOLEAN ARRAYED_LIST [DOCKER_CONTAINER] List containers. If a_all is True, includes stopped containers.
get_container a_id: STRING DOCKER_CONTAINER Get container by ID or name.
create_container a_spec: CONTAINER_SPEC DOCKER_CONTAINER Create container from specification.
run_container a_spec: CONTAINER_SPEC DOCKER_CONTAINER Create and start container.
start_container a_id: STRING BOOLEAN Start a stopped container.
stop_container a_id: STRING; a_timeout: INTEGER BOOLEAN Stop container with timeout in seconds.
restart_container a_id: STRING; a_timeout: INTEGER BOOLEAN Restart container.
pause_container a_id: STRING BOOLEAN Pause container.
unpause_container a_id: STRING BOOLEAN Unpause container.
kill_container a_id: STRING BOOLEAN Kill container (SIGKILL).
remove_container a_id: STRING; a_force: BOOLEAN BOOLEAN Remove container. Force removes running containers.
container_logs a_id: STRING; a_stdout, a_stderr: BOOLEAN; a_tail: INTEGER STRING Get container logs. Tail specifies line count.
wait_container a_id: STRING INTEGER Wait for container to exit. Returns exit code.

Image Operations

FeatureParametersReturnDescription
list_images - ARRAYED_LIST [DOCKER_IMAGE] List all local images.
get_image a_name: STRING DOCKER_IMAGE Get image by name or ID.
image_exists a_name: STRING BOOLEAN Check if image exists locally.
pull_image a_name: STRING BOOLEAN Pull image from registry.
remove_image a_name: STRING; a_force: BOOLEAN BOOLEAN Remove image. Force removes even if in use.

Network Operations

FeatureParametersReturnDescription
list_networks - ARRAYED_LIST [DOCKER_NETWORK] List all networks.
get_network a_id: STRING DOCKER_NETWORK Get network by ID or name.
create_network a_name, a_driver: STRING DOCKER_NETWORK Create network with driver.
remove_network a_id: STRING BOOLEAN Remove network.
connect_container_to_network a_network_id, a_container_id: STRING BOOLEAN Connect container to network.
disconnect_container_from_network a_network_id, a_container_id: STRING; a_force: BOOLEAN BOOLEAN Disconnect container from network.
prune_networks - INTEGER Remove unused networks. Returns count.

Volume Operations

FeatureParametersReturnDescription
list_volumes - ARRAYED_LIST [DOCKER_VOLUME] List all volumes.
get_volume a_name: STRING DOCKER_VOLUME Get volume by name.
create_volume a_name: STRING DOCKER_VOLUME Create volume with local driver.
create_volume_with_driver a_name, a_driver: STRING DOCKER_VOLUME Create volume with specific driver.
remove_volume a_name: STRING; a_force: BOOLEAN BOOLEAN Remove volume.
prune_volumes - INTEGER Remove unused volumes. Returns count.

Exec Operations

FeatureParametersReturnDescription
exec_in_container a_container_id: STRING; a_command: ARRAY [STRING] STRING Execute command and return output.
create_exec a_container_id: STRING; a_command: ARRAY [STRING]; a_attach_stdout, a_attach_stderr: BOOLEAN STRING Create exec instance. Returns exec ID.
start_exec a_exec_id: STRING STRING Start exec and return output.
inspect_exec a_exec_id: STRING SIMPLE_JSON_OBJECT Get exec details including exit code.

Error Handling

FeatureReturn TypeDescription
has_errorBOOLEANDid last operation fail?
last_errorDOCKER_ERRORError from last operation (if any).

CONTAINER_SPEC

Fluent builder for container configuration. All setters return Current for chaining.

Creation

make (a_image: STRING)

Create specification for given image.

Preconditions

image_not_empty: not a_image.is_empty

Postconditions

image_set: image.same_string (a_image)

Basic Configuration

FeatureParameterDescription
set_namea_name: STRINGContainer name (must be unique)
set_hostnamea_hostname: STRINGContainer hostname
set_working_dira_dir: STRINGWorking directory inside container
set_usera_user: STRINGUser to run as (user or user:group)

Command Configuration

FeatureParameterDescription
set_cmda_cmd: ARRAY [STRING]Command to run
set_entrypointa_entrypoint: ARRAY [STRING]Container entrypoint

Environment

FeatureParametersDescription
add_enva_key, a_value: STRINGAdd environment variable

Port Mapping

FeatureParametersDescription
add_porta_container, a_host: INTEGERMap TCP port
add_port_udpa_container, a_host: INTEGERMap UDP port

Volume Mounts

FeatureParametersDescription
add_volumea_host, a_container: STRINGMount volume read-write
add_volume_readonlya_host, a_container: STRINGMount volume read-only

Resource Limits

FeatureParameterDescription
set_memory_limita_bytes: INTEGER_64Memory limit in bytes
set_cpu_sharesa_shares: INTEGERCPU shares (relative weight)

Policies

FeatureParameterValues
set_restart_policya_policy: STRINGno, always, on-failure, unless-stopped
set_network_modea_mode: STRINGbridge, host, none, container:name
set_auto_removea_auto: BOOLEANRemove container on exit

Terminal

FeatureParameterDescription
set_ttya_tty: BOOLEANAllocate pseudo-TTY
set_stdin_opena_open: BOOLEANKeep STDIN open

Labels

FeatureParametersDescription
add_labela_key, a_value: STRINGAdd metadata label

Export

FeatureReturnDescription
to_jsonSIMPLE_JSON_OBJECTExport as JSON for Docker API

DOCKER_CONTAINER

Container representation with state and metadata.

Identification

FeatureTypeDescription
idSTRINGFull container ID (64 hex chars)
short_idSTRINGShort ID (12 chars)
nameSTRINGContainer name (without leading /)
namesARRAYED_LIST [STRING]All container names

Image Information

FeatureTypeDescription
imageSTRINGImage name
image_idSTRINGImage ID
commandSTRINGCommand being run

State Queries

FeatureTypeDescription
stateSTRINGCurrent state string
statusSTRINGHuman-readable status
is_runningBOOLEANIs container running?
is_pausedBOOLEANIs container paused?
is_exitedBOOLEANHas container exited?
is_deadBOOLEANIs container dead?
exit_codeINTEGERExit code (if exited)

Transition Queries

FeatureTypeDescription
can_startBOOLEANCan container be started?
can_stopBOOLEANCan container be stopped?
has_exited_successfullyBOOLEANExited with code 0?

Network

FeatureTypeDescription
ip_addressSTRINGContainer IP address
portsARRAYED_LIST [TUPLE]Port mappings

Metadata

FeatureTypeDescription
created_timestampINTEGER_64Unix timestamp of creation
labelsARRAYED_LIST [TUPLE]Container labels

DOCKER_IMAGE

Image representation with tags and metadata.

Identification

FeatureTypeDescription
idSTRINGFull image ID
short_idSTRINGShort ID (12 chars)
repo_tagsARRAYED_LIST [STRING]Repository tags
repo_digestsARRAYED_LIST [STRING]Repository digests

Tag Queries

FeatureTypeDescription
primary_tagSTRINGFirst tag or "<none>"
repositorySTRINGRepository name from primary tag
tagSTRINGTag from primary tag
has_tag (a_tag)BOOLEANDoes image have this tag?
matches (a_ref)BOOLEANMatch by name, tag, or ID

Size

FeatureTypeDescription
sizeINTEGER_64Image size in bytes
virtual_sizeINTEGER_64Virtual size in bytes
size_mbREAL_64Size in megabytes

Metadata

FeatureTypeDescription
created_timestampINTEGER_64Unix timestamp of creation
containersINTEGERNumber of containers using image
labelsARRAYED_LIST [TUPLE]Image labels

DOCKER_ERROR

Error representation with classification.

Error Information

FeatureTypeDescription
messageSTRINGError message
status_codeINTEGERHTTP status code
error_typeINTEGERError type constant

Error Type Queries

FeatureDescription
is_connection_errorCannot connect to Docker daemon
is_timeout_errorOperation timed out
is_not_foundResource not found (404)
is_conflictConflict error (409)
is_server_errorDocker daemon error (5xx)
is_client_errorClient error (4xx)
is_retryableCan operation be retried?

CONTAINER_STATE

State constants and transition queries.

State Constants

ConstantValue
created"created"
running"running"
paused"paused"
restarting"restarting"
removing"removing"
exited"exited"
dead"dead"

State Queries

FeatureDescription
is_valid_state (s)Is s a valid state?
is_running_state (s)Is s running or paused?
is_stopped_state (s)Is s exited or dead?

Transition Queries

FeatureDescription
can_start (s)Can container in state s be started?
can_stop (s)Can container in state s be stopped?
can_pause (s)Can container in state s be paused?
can_remove (s)Can container in state s be removed?

DOCKERFILE_BUILDER

Fluent builder for Dockerfile generation. Supports multi-stage builds.

Creation

make (a_base_image: STRING)

Create builder with base image.

make_multi_stage

Create builder for multi-stage builds (no initial FROM).

FROM Instructions

FeatureParametersDescription
from_imagea_image: STRINGAdd FROM instruction
from_image_asa_image, a_stage_name: STRINGFROM with stage name

Build Instructions

FeatureParametersDescription
runa_command: STRINGRUN instruction (shell form)
run_execa_args: ARRAY [STRING]RUN instruction (exec form)
run_multia_commands: ARRAY [STRING]RUN with && chaining
copy_filesa_src, a_dest: STRINGCOPY instruction
copy_froma_stage, a_src, a_dest: STRINGCOPY --from for multi-stage
adda_src, a_dest: STRINGADD instruction
workdira_dir: STRINGWORKDIR instruction

Environment and Args

FeatureParametersDescription
enva_key, a_value: STRINGENV instruction
arga_name: STRINGARG without default
arg_defaulta_name, a_default: STRINGARG with default value
labela_key, a_value: STRINGLABEL instruction

Runtime Configuration

FeatureParametersDescription
exposea_port: INTEGEREXPOSE TCP port
expose_udpa_port: INTEGEREXPOSE UDP port
cmda_args: ARRAY [STRING]CMD (exec form)
cmd_shella_command: STRINGCMD (shell form)
entrypointa_args: ARRAY [STRING]ENTRYPOINT (exec form)
usera_user: STRINGUSER instruction
volumea_path: STRINGVOLUME instruction
healthchecka_cmd: STRINGHEALTHCHECK CMD

Output

FeatureReturnDescription
to_stringSTRINGGenerate Dockerfile content
save_to_fileBOOLEANSave to file path

DOCKER_NETWORK

Network representation with configuration and connected containers.

Identification

FeatureTypeDescription
idSTRINGFull network ID
short_idSTRINGShort ID (12 chars)
nameSTRINGNetwork name
driverSTRINGNetwork driver (bridge, host, overlay)
scopeSTRINGScope (local, global, swarm)

IPAM

FeatureTypeDescription
ipam_driver_nameSTRINGIPAM driver
ipam_subnetSTRINGSubnet (e.g., "172.17.0.0/16")
ipam_gatewaySTRINGGateway (e.g., "172.17.0.1")

Configuration Flags

FeatureTypeDescription
enable_ipv6BOOLEANIPv6 enabled?
is_internalBOOLEANInternal network?
is_attachableBOOLEANCan attach containers?
is_ingressBOOLEANSwarm ingress network?

Containers

FeatureTypeDescription
containersARRAYED_LIST [TUPLE]Connected containers
container_countINTEGERNumber of containers
has_containerBOOLEANIs container connected?

Type Queries

FeatureDescription
is_bridgeBridge network?
is_hostHost network?
is_overlayOverlay network?
is_defaultDefault Docker network?
matchesMatch by ID, short ID, or name

DOCKER_VOLUME

Volume representation with driver and mount information.

Identification

FeatureTypeDescription
nameSTRINGVolume name
driverSTRINGVolume driver (local, nfs, etc.)
mountpointSTRINGHost mount path
scopeSTRINGScope (local, global)
created_atSTRINGCreation timestamp

Usage

FeatureTypeDescription
sizeINTEGER_64Size in bytes
size_mbREAL_64Size in megabytes
size_gbREAL_64Size in gigabytes
ref_countINTEGERContainer references

Labels and Options

FeatureTypeDescription
labelsARRAYED_LIST [TUPLE]Volume labels
optionsARRAYED_LIST [TUPLE]Driver options
has_labelBOOLEANHas label with key?
label_valueSTRINGGet label value

Queries

FeatureDescription
is_localLocal driver volume?
is_in_useUsed by any container?
is_anonymousAnonymous volume (64-char hex)?
matchesMatch by name