Apero.Docker (Apero v1.0.0)

Copy Markdown View Source

Docker / Podman container lifecycle management.

Detects the available container runtime (Docker or Podman) and provides a unified interface for container and compose operations.

Container detection

Use runtime/0 to detect the available runtime, or set the RUNTIME environment variable to override (docker or podman).

Summary

Functions

Builds images.

Stops and removes services.

Executes a command in a service container.

Returns true if running inside a container.

Shows logs.

Lists networks.

Lists running services.

Pulls images.

Restarts services.

Detects the available container runtime.

Starts services defined in docker-compose.yml.

Lists volumes.

Types

runtime()

@type runtime() :: :docker | :podman

Functions

build(opts \\ [])

@spec build(keyword()) :: {:ok, binary()} | {:error, binary()}

Builds images.

down(opts \\ [])

@spec down(keyword()) :: {:ok, binary()} | {:error, binary()}

Stops and removes services.

exec(service, command, opts \\ [])

@spec exec(binary(), [binary()], keyword()) :: {:ok, binary()} | {:error, binary()}

Executes a command in a service container.

in_container?()

@spec in_container?() :: boolean()

Returns true if running inside a container.

logs(opts \\ [])

@spec logs(keyword()) :: {:ok, binary()} | {:error, binary()}

Shows logs.

network_create(name, opts \\ [])

@spec network_create(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Creates a network.

network_list(opts \\ [])

@spec network_list(keyword()) :: {:ok, binary()} | {:error, binary()}

Lists networks.

network_remove(name, opts \\ [])

@spec network_remove(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Removes a network.

ps(opts \\ [])

@spec ps(keyword()) :: {:ok, binary()} | {:error, binary()}

Lists running services.

pull(opts \\ [])

@spec pull(keyword()) :: {:ok, binary()} | {:error, binary()}

Pulls images.

restart(opts \\ [])

@spec restart(keyword()) :: {:ok, binary()} | {:error, binary()}

Restarts services.

runtime()

@spec runtime() :: runtime() | :none

Detects the available container runtime.

up(opts \\ [])

@spec up(keyword()) :: {:ok, binary()} | {:error, binary()}

Starts services defined in docker-compose.yml.

volume_create(name, opts \\ [])

@spec volume_create(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Creates a volume.

volume_list(opts \\ [])

@spec volume_list(keyword()) :: {:ok, binary()} | {:error, binary()}

Lists volumes.

volume_remove(name, opts \\ [])

@spec volume_remove(
  binary(),
  keyword()
) :: {:ok, binary()} | {:error, binary()}

Removes a volume.