Skip to main content

CreateContainerRequest

Struct CreateContainerRequest 

Source
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: String

OCI 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: bool

Mount 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).

§cpu_shares: Option<u32>

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: LifecycleSpec

Container 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.

Trait Implementations§

Source§

impl ComposeSchema for CreateContainerRequest

Source§

impl Debug for CreateContainerRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CreateContainerRequest

Source§

fn default() -> CreateContainerRequest

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CreateContainerRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CreateContainerRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToSchema for CreateContainerRequest

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference utoipa::openapi::schema::Schemas for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromBase64 for T
where T: for<'de> Deserialize<'de>,

Source§

fn from_base64<Input>(raw: &Input) -> Result<T, Error>
where Input: AsRef<[u8]> + ?Sized,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

Source§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<C> SignWithKey<String> for C
where C: ToBase64,

Source§

impl<T> ToBase64 for T
where T: Serialize,

Source§

fn to_base64(&self) -> Result<Cow<'_, str>, Error>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,