pub struct ServiceSpec {Show 29 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 devices: Vec<DeviceSpec>,
pub storage: Vec<StorageSpec>,
pub port_mappings: Vec<PortMapping>,
pub capabilities: 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>,
}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
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)
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).
Trait Implementations§
Source§impl Clone for ServiceSpec
impl Clone for ServiceSpec
Source§fn clone(&self) -> ServiceSpec
fn clone(&self) -> ServiceSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more