pub struct ServiceSpec {Show 49 fields
pub rtype: ResourceType,
pub schedule: Option<String>,
pub image: ImageSpec,
pub resources: ResourcesSpec,
pub env: HashMap<String, String>,
pub command: CommandSpec,
pub network: ServiceNetworkSpec,
pub endpoints: Vec<EndpointSpec>,
pub scale: ScaleSpec,
pub depends: Vec<DependsSpec>,
pub health: HealthSpec,
pub init: InitSpec,
pub errors: ErrorsSpec,
pub lifecycle: LifecycleSpec,
pub devices: Vec<DeviceSpec>,
pub storage: Vec<StorageSpec>,
pub port_mappings: Vec<PortMapping>,
pub capabilities: Vec<String>,
pub cap_drop: Vec<String>,
pub privileged: bool,
pub node_mode: NodeMode,
pub node_selector: Option<NodeSelector>,
pub platform: Option<TargetPlatform>,
pub service_type: ServiceType,
pub wasm: Option<WasmConfig>,
pub logs: Option<LogsConfig>,
pub host_network: bool,
pub hostname: Option<String>,
pub dns: Vec<String>,
pub extra_hosts: Vec<String>,
pub restart_policy: Option<ContainerRestartPolicy>,
pub labels: HashMap<String, String>,
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 security_opt: Vec<String>,
pub pid_mode: Option<String>,
pub ipc_mode: Option<String>,
pub network_mode: NetworkMode,
pub extra_groups: Vec<String>,
pub read_only_root_fs: bool,
pub init_container: Option<bool>,
pub tty: bool,
pub stdin_open: bool,
pub userns_mode: Option<String>,
pub cgroup_parent: Option<String>,
pub expose: Vec<String>,
}Expand description
Per-service specification
Fields§
§rtype: ResourceTypeResource type (service, job, cron)
schedule: Option<String>Cron schedule expression (only for rtype: cron) Uses 7-field cron syntax: “sec min hour day-of-month month day-of-week year” Examples:
- “0 0 0 * * * *” (daily at midnight)
- “0 */5 * * * * *” (every 5 minutes)
- “0 0 12 * * MON-FRI *” (weekdays at noon)
image: ImageSpecContainer image specification
resources: ResourcesSpecResource limits
env: HashMap<String, String>Environment variables for the service
Values can be:
- Plain strings:
"value" - Host env refs:
$E:VAR_NAME - Secret refs:
$S:secret-nameor$S:@service/secret-name
command: CommandSpecCommand override (entrypoint, args, workdir)
network: ServiceNetworkSpecNetwork configuration
endpoints: Vec<EndpointSpec>Endpoint definitions (proxy bindings)
scale: ScaleSpecScaling configuration
depends: Vec<DependsSpec>Dependency specifications
health: HealthSpecHealth check configuration
init: InitSpecInit actions (pre-start lifecycle steps)
errors: ErrorsSpecError handling policies
lifecycle: LifecycleSpecContainer lifecycle policy (e.g., delete-on-exit).
Purely declarative on this type; downstream layers (agent / API / scheduler) read this field to decide whether to clean up the container record after termination.
devices: Vec<DeviceSpec>Device passthrough (e.g., /dev/kvm for VMs)
storage: Vec<StorageSpec>Storage mounts for the container
port_mappings: Vec<PortMapping>Host-to-container port mappings (Docker’s -p host:container/proto).
Each entry publishes a container port on the host. When host_port is
None (or zero), the daemon assigns an ephemeral host port.
capabilities: Vec<String>Linux capabilities to add (e.g., SYS_ADMIN, NET_ADMIN).
Also accepts the Docker-compatible alias cap_add on input.
cap_drop: Vec<String>Linux capabilities to drop (Docker --cap-drop).
privileged: boolRun container in privileged mode (all capabilities + all devices)
node_mode: NodeModeNode allocation mode (shared, dedicated, exclusive)
node_selector: Option<NodeSelector>Node selection constraints (required/preferred labels)
platform: Option<TargetPlatform>Target platform for this service. When None (default), the service is
eligible to run on any agent regardless of OS/architecture. When Some,
the scheduler will only place replicas on agents whose platform matches.
service_type: ServiceTypeService type (standard, wasm_http, wasm_plugin, etc.)
wasm: Option<WasmConfig>WASM configuration (used when service_type is any Wasm* variant)
Also accepts the deprecated wasm_http key for backward compatibility.
logs: Option<LogsConfig>Log output configuration. If not set, uses platform defaults.
host_network: boolUse host networking (container shares host network namespace)
When true, the container will NOT get its own network namespace.
This is set programmatically via the --host-network CLI flag, not in YAML specs.
hostname: Option<String>Container hostname (maps to Docker’s --hostname).
When set, the container’s /etc/hostname and initial kernel hostname
are configured to this value. Ignored when host_network is true
(the container inherits the host’s hostname).
dns: Vec<String>Additional DNS servers for the container (maps to Docker’s --dns).
Each entry must be a plausible IPv4 or IPv6 address. Forwarded to the
container runtime as resolver addresses ahead of the platform defaults.
Ignored when host_network is true.
extra_hosts: Vec<String>Extra hostname:ip entries appended to /etc/hosts (maps to Docker’s
--add-host).
Each entry must be in the form "<hostname>:<ip>". The special literal
host-gateway is accepted as the <ip> half (resolved by Docker /
bollard to the host-visible gateway address, commonly used with
host.docker.internal:host-gateway).
restart_policy: Option<ContainerRestartPolicy>Container restart policy (Docker-style).
Controls when the runtime should automatically restart the container
after it exits. Maps to Docker’s HostConfig.RestartPolicy. Named
ContainerRestartPolicy to avoid colliding with ZLayer’s existing
PanicPolicy (which controls post-panic behavior, not runtime-level
restarts).
labels: HashMap<String, String>Free-form key/value labels attached to the container
(Docker --label).
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).
sysctls: HashMap<String, String>Kernel sysctl overrides (Docker --sysctl).
ulimits: HashMap<String, UlimitSpec>Per-process ulimits (Docker --ulimit).
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>".
network_mode: NetworkModeNetwork mode (Docker --network). Accepts both the enum-tagged form
and the Docker-style strings ("host", "none", "bridge",
"bridge:<name>", "container:<id>").
extra_groups: Vec<String>Additional groups to add to the container process
(Docker --group-add).
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 ServiceSpec::init which controls
ZLayer’s pre-start init actions.
tty: boolAllocate a TTY for the container’s main process (Docker --tty,
compose tty: true).
stdin_open: boolKeep STDIN open even when nothing is attached (Docker --interactive,
compose stdin_open: true).
userns_mode: Option<String>User namespace mode (Docker --userns). Accepts e.g. "host" or
a remap-spec name configured on the daemon.
cgroup_parent: Option<String>Cgroup parent path (Docker --cgroup-parent). When set, the runtime
places the container under the given cgroup hierarchy.
expose: Vec<String>Container ports exposed but not published to the host (compose
expose:). Each entry is a port string, optionally port/proto
(e.g. "3000", "8080/tcp"). Treated as documentation by the
runtime; downstream networking layers may use this list to allow
inter-service traffic without publishing to the host.
Trait Implementations§
Source§impl Clone for ServiceSpec
impl Clone for ServiceSpec
Source§fn clone(&self) -> ServiceSpec
fn clone(&self) -> ServiceSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ServiceSpec
impl Debug for ServiceSpec
Source§impl<'de> Deserialize<'de> for ServiceSpec
impl<'de> Deserialize<'de> for ServiceSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ServiceSpec
impl PartialEq for ServiceSpec
Source§fn eq(&self, other: &ServiceSpec) -> bool
fn eq(&self, other: &ServiceSpec) -> bool
self and other values to be equal, and is used by ==.