Detects which container engine is in use: Docker, Podman, minikube, or Apple Container.
Precedence
- Runtime override — set via
set_engine/1(highest priority, per-process). CONTAINER_ENGINEenv var — explicit selection (docker,podman,colima,minikube,apple_container). When set, auto-detection is skipped entirely.CONTAINER_ENGINE_HOST/CONTAINER_HOSTenv vars — if the URL containspodmanor matches minikube subnets, the engine is inferred from the URL.MINIKUBE_ACTIVE_DOCKERD/MINIKUBE_PROFILEenv vars.- Apple Container — only when the
containerbinary exists, the service reports "running", and the API socket exists. - Podman ping — HTTP ping to the daemon checking for a Podman header.
- Default —
:docker.
Runtime engine selection
You can override the auto-detected engine at runtime:
TestcontainerEx.set_engine(:podman)
TestcontainerEx.container_engine() # => :podmanTo reset back to auto-detection:
TestcontainerEx.clear_engine()The override is stored per-process in the process dictionary, so it does not affect other processes and is cleaned up automatically when the calling process exits.
Summary
Functions
Returns true when running with Apple Container.
Clears a runtime engine override, restoring auto-detection.
Detects the container engine type.
Returns true when running in a minikube environment.
Returns true when running with Podman.
Returns the runtime override for the calling process, or nil if no
override has been set.
Overrides the auto-detected engine at runtime.
Functions
@spec apple_container?() :: boolean()
Returns true when running with Apple Container.
@spec clear_engine() :: :ok
Clears a runtime engine override, restoring auto-detection.
Also clears the :persistent_term cache so the next detect/0 call
re-runs the full auto-detection sequence.
Examples
iex> TestcontainerEx.clear_engine()
:ok
@spec detect() :: :docker | :podman | :minikube | :apple_container
Detects the container engine type.
Returns one of:
:apple_container— Apple Container runtime:podman— Podman:minikube— Minikube:docker— Docker (default)
Resolution order:
- Runtime override (set via
set_engine/1) — per-process, highest priority - Cached auto-detection result (stored in
:persistent_term) - Fresh auto-detection (cached for subsequent calls)
When CONTAINER_ENGINE env var is set to a valid engine, auto-detection
is skipped entirely and that value is used directly.
@spec minikube?() :: boolean()
Returns true when running in a minikube environment.
@spec podman?() :: boolean()
Returns true when running with Podman.
@spec runtime_override() ::
:docker | :podman | :colima | :minikube | :apple_container | nil
Returns the runtime override for the calling process, or nil if no
override has been set.
@spec set_engine(:docker | :podman | :colima | :minikube | :apple_container) :: :ok
Overrides the auto-detected engine at runtime.
The override is stored in the calling process's dictionary, so it:
- Takes precedence over
CONTAINER_ENGINEenv var and auto-detection - Only affects the calling process (and its children via
Process.info/1inheritance) - Is cleaned up automatically when the process exits
Examples
iex> TestcontainerEx.set_engine(:podman)
:ok
iex> TestcontainerEx.container_engine()
:podman