pub struct CreateContainerRequest {Show 44 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>,
pub privileged: Option<bool>,
pub cap_add: Vec<String>,
pub cap_drop: Vec<String>,
pub devices: Vec<DeviceSpec>,
pub network_mode: Option<NetworkMode>,
pub security_opt: Vec<String>,
pub pid_mode: Option<String>,
pub ipc_mode: Option<String>,
pub read_only_root_fs: bool,
pub init_container: Option<bool>,
pub user: Option<String>,
pub stop_signal: Option<String>,
pub stop_grace_period: Option<Duration>,
pub sysctls: HashMap<String, String>,
pub ulimits: HashMap<String, UlimitSpec>,
pub extra_groups: Vec<String>,
pub pids_limit: Option<i64>,
pub cpuset: Option<String>,
pub cpu_shares: Option<u32>,
pub memory_swap: Option<String>,
pub memory_reservation: Option<String>,
pub memory_swappiness: Option<u8>,
pub oom_score_adj: Option<i32>,
pub oom_kill_disable: Option<bool>,
pub blkio_weight: Option<u16>,
pub lifecycle: LifecycleSpec,
}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.
privileged: Option<bool>Run the container in privileged mode (Docker --privileged). When
omitted, defaults to false.
cap_add: Vec<String>Linux capabilities to add (Docker --cap-add). Maps to
ServiceSpec::capabilities.
cap_drop: Vec<String>Linux capabilities to drop (Docker --cap-drop).
devices: Vec<DeviceSpec>Host devices to expose to the container (Docker --device).
network_mode: Option<NetworkMode>Network mode (Docker --network). Accepts "default", "host",
"none", "bridge", "bridge:<name>", or "container:<id>". When
omitted, defaults to crate::spec::NetworkMode::Default.
security_opt: Vec<String>Security options such as apparmor=..., seccomp=...,
no-new-privileges:true (Docker --security-opt).
pid_mode: Option<String>PID namespace mode (Docker --pid). Accepts e.g. "host" or
"container:<id>".
ipc_mode: Option<String>IPC namespace mode (Docker --ipc). Accepts e.g. "host",
"shareable", "private", or "container:<id>".
read_only_root_fs: boolMount the container’s root filesystem read-only (Docker --read-only).
init_container: Option<bool>Run a Docker-supplied init process (PID 1) inside the container
(Docker --init). Distinct from ZLayer’s pre-start init actions.
user: Option<String>User and group override for the container’s main process
(Docker --user uid:gid).
stop_signal: Option<String>Signal sent to the container’s main process to request a graceful
shutdown (Docker --stop-signal). Accepts e.g. "SIGTERM" or "15".
stop_grace_period: Option<Duration>Grace period to wait between the stop signal and a forced kill
(Docker --stop-timeout). Wire format is a humantime string
(e.g. "30s", "500ms", "1m").
sysctls: HashMap<String, String>Kernel sysctl overrides (Docker --sysctl).
ulimits: HashMap<String, UlimitSpec>Per-process ulimits (Docker --ulimit).
extra_groups: Vec<String>Additional groups to add to the container process
(Docker --group-add).
pids_limit: Option<i64>Maximum number of processes the container may spawn
(Docker --pids-limit).
cpuset: Option<String>CPUs that the container is allowed to execute on
(Docker --cpuset-cpus).
Relative CPU shares (Docker --cpu-shares). Default weight is 1024.
memory_swap: Option<String>Total memory limit including swap (Docker --memory-swap).
memory_reservation: Option<String>Soft memory limit (Docker --memory-reservation).
memory_swappiness: Option<u8>Container memory swappiness, 0-100 (Docker --memory-swappiness).
oom_score_adj: Option<i32>OOM-killer score adjustment (Docker --oom-score-adj).
oom_kill_disable: Option<bool>Disable the OOM killer for the container (Docker --oom-kill-disable).
blkio_weight: Option<u16>Block IO weight, 10-1000 (Docker --blkio-weight).
lifecycle: LifecycleSpecContainer lifecycle policy. Carries the delete_on_exit knob (Docker
--rm / HostConfig.AutoRemove) so the daemon can remove terminated
container records and bundles once they exit. Defaults to
crate::spec::LifecycleSpec::default() (i.e. retain on exit), which
matches the historical behavior for callers that omit the field.