simple_docker

Docker Container Management for Eiffel

v1.4.0 MIT

Overview

simple_docker is an Eiffel library for programmatic Docker container management. It provides a clean, type-safe API for building, running, and managing Docker containers through Windows named pipes, communicating directly with the Docker Engine API.

Part of the Simple Eiffel ecosystem.

Quick Start

Installation

  1. Set the environment variable:
    export SIMPLE_EIFFEL=/d/prod
  2. Add to your ECF file:
    <library name="simple_docker" location="$SIMPLE_EIFFEL/simple_docker/simple_docker.ecf"/>

Beginner API (SIMPLE_DOCKER_QUICK)

Don't know Docker? No problem! One-liner operations:

local
    docker: SIMPLE_DOCKER_QUICK
do
    create docker.make

    -- Run a web server on port 8080
    docker.web_server ("C:\my_website", 8080)

    -- Run PostgreSQL database
    docker.postgres ("mypassword")

    -- Run Redis cache
    docker.redis

    -- Run a shell script
    print (docker.run_script ("echo hello && date"))

    -- Clean up when done
    docker.cleanup
end

Full API (DOCKER_CLIENT)

Need full control? Use the advanced API:

local
    client: DOCKER_CLIENT
    spec: CONTAINER_SPEC
do
    create client.make

    if client.ping then
        -- Docker daemon is responsive
        create spec.make ("alpine:latest")
        spec.set_name ("my-container")
            .set_cmd (<<"echo", "Hello from Eiffel!">>)
            .add_env ("FOO", "bar").do_nothing

        if attached client.run_container (spec) as c then
            print ("Created: " + c.short_id + "%N")
        end
    end
end

Key Features

Zero-Config Beginner API

One-liner operations for web servers, databases, caches, and scripts. No Docker knowledge required!

Container Lifecycle

Create, start, stop, pause, restart, kill, and remove containers with full state tracking.

Image Management

List, pull, inspect, and remove Docker images from local and remote registries.

Fluent Builder API

Configure containers using intuitive chained method calls with full type safety.

Design by Contract

Full DBC support with preconditions, postconditions, and class invariants.

Named Pipe Transport

Direct communication with Docker Engine via Windows named pipes.

Chunked Transfer

Proper HTTP/1.1 chunked transfer encoding for reliable API communication.

Dockerfile Builder

Fluent API for generating Dockerfiles with multi-stage build support.

Network Management

Create, list, connect, and disconnect containers from Docker networks.

Volume Management

Create, list, and remove Docker volumes with driver configuration.

Exec Operations

Execute commands in running containers and capture output.

Resilient IPC

Automatic retry with configurable delays on transient connection failures.

Strong Contracts

Comprehensive DBC with preconditions, postconditions, and invariants on all operations.

Documentation

Dependencies