Skip to content

container

The container module manages containers using Docker or Podman. The runtime is auto-detected, or can be specified explicitly.

container "myapp" {
image "registry.example.com/myapp:latest"
state "running"
runtime "podman"
install-runtime #true
restart "always"
ports {
- "8080:80"
- "8443:443"
}
environment {
DATABASE_URL "postgres://db:5432/app"
LOG_LEVEL "info"
}
volumes {
- "/data/myapp:/app/data"
}
}
ParameterTypeDescription
(positional)stringContainer name
imagestringContainer image reference
statestring"running", "stopped", or "absent"
runtimestring"docker" or "podman" (default: auto-detect)
install-runtimebooleanAuto-install the runtime if not found
restartstringRestart policy: "always", "on-failure", "no"
portslistPort mappings (host:container)
environmentmapEnvironment variables
volumeslistVolume mounts (host:container)

The module checks if a container with the given name exists and is in the desired state. For running, it also verifies the image matches. If a container exists with a different image, it is replaced.

See the container-app example for a complete containerized deployment.