pub struct CreateContainerRequest {Show 18 fields
pub image: String,
pub name: Option<String>,
pub pull_policy: Option<String>,
pub env: HashMap<String, String>,
pub command: Option<Vec<String>>,
pub labels: HashMap<String, String>,
pub resources: Option<ContainerResourceLimits>,
pub volumes: Vec<VolumeMount>,
pub ports: Vec<PortMapping>,
pub work_dir: Option<String>,
pub health_check: Option<HealthCheckRequest>,
pub hostname: Option<String>,
pub dns: Vec<String>,
pub extra_hosts: Vec<String>,
pub restart_policy: Option<ContainerRestartPolicy>,
pub networks: Vec<NetworkAttachmentRequest>,
pub registry_credential_id: Option<String>,
pub registry_auth: Option<RegistryAuth>,
}Expand description
Request to create and start a container
Fields§
§image: StringOCI image reference (e.g., “nginx:latest”, “ubuntu:22.04”)
name: Option<String>Optional human-readable name
pull_policy: Option<String>Image pull policy: “always”, “if_not_present”, or “never”
env: HashMap<String, String>Environment variables
command: Option<Vec<String>>Command to run (overrides image entrypoint)
labels: HashMap<String, String>Labels for filtering and grouping
resources: Option<ContainerResourceLimits>Resource limits (CPU, memory)
volumes: Vec<VolumeMount>Volume mounts
ports: Vec<PortMapping>Published ports (Docker’s -p host:container/proto). When omitted,
the container is created without any host port publishing.
work_dir: Option<String>Working directory inside the container
health_check: Option<HealthCheckRequest>Optional health check. When omitted, the daemon installs a no-op
placeholder (HealthCheck::Tcp { port: 0 }) matching the current
default; the health monitor treats port == 0 as “skip”.
hostname: Option<String>Optional container hostname (maps to Docker’s --hostname).
dns: Vec<String>Additional DNS servers (maps to Docker’s --dns). Each entry must be
a plausible IPv4 or IPv6 address.
extra_hosts: Vec<String>Extra hostname:ip entries appended to /etc/hosts (maps to Docker’s
--add-host). The special literal host-gateway is accepted as the
ip half.
restart_policy: Option<ContainerRestartPolicy>Container restart policy (Docker-style). When omitted, the runtime
applies no explicit restart policy (Docker default: "no").
networks: Vec<NetworkAttachmentRequest>User-defined bridge/overlay networks to attach the newly-created container to. Each entry references a network by id or name and is attached after the container is successfully started. If any attachment fails, the partially-started container is rolled back (stopped + removed) and the request is failed.
registry_credential_id: Option<String>Id of a persisted registry credential (from
POST /api/v1/credentials/registry) to use when pulling the image.
Ignored when Self::registry_auth is also supplied (inline auth
wins). Requires the daemon to be configured with a credential store
— otherwise the request is rejected with 400.
registry_auth: Option<RegistryAuth>Inline Docker/OCI registry credentials used for this pull only. Not
persisted, never logged, never echoed back on a response. When both
registry_credential_id and registry_auth are set, this field
takes precedence.