pub struct Service {Show 93 fields
pub extends: Option<Extends>,
pub container_name: Option<String>,
pub hostname: Option<String>,
pub image: Option<String>,
pub build_: Option<BuildStep>,
pub depends_on: Option<DependsOn>,
pub command: Option<StringOrList>,
pub entrypoint: Option<StringOrList>,
pub healthcheck: Option<Healthcheck>,
pub expose: BTreeSet<StringOrNum>,
pub env_file: Option<Envfile>,
pub environment: ListOrMap,
pub annotations: ListOrMap,
pub attach: Option<bool>,
pub blkio_config: Option<BlkioSettings>,
pub cap_add: BTreeSet<String>,
pub cap_drop: BTreeSet<String>,
pub cgroup: Option<Cgroup>,
pub cgroup_parent: Option<String>,
pub configs: BTreeSet<ServiceConfigOrSecret>,
pub cpu_count: Option<StringOrNum>,
pub cpu_percent: Option<StringOrNum>,
pub cpu_period: Option<StringOrNum>,
pub cpu_quota: Option<StringOrNum>,
pub cpu_shares: Option<StringOrNum>,
pub cpu_rt_period: Option<StringOrNum>,
pub cpu_rt_runtime: Option<StringOrNum>,
pub cpus: Option<StringOrNum>,
pub cpuset: Option<String>,
pub credential_spec: Option<CredentialSpec>,
pub deploy: Option<Deploy>,
pub develop: Option<DevelopmentSettings>,
pub device_cgroup_rules: BTreeSet<String>,
pub devices: BTreeSet<DeviceMapping>,
pub dns: StringOrSortedList,
pub dns_opt: BTreeSet<String>,
pub dns_search: StringOrSortedList,
pub domainname: Option<String>,
pub driver_opts: BTreeMap<String, StringOrNum>,
pub external_links: BTreeSet<String>,
pub extra_hosts: Option<ExtraHosts>,
pub gpus: Option<Gpus>,
pub group_add: BTreeSet<StringOrNum>,
pub init: Option<bool>,
pub ipc: Option<String>,
pub isolation: Option<String>,
pub labels: ListOrMap,
pub label_file: StringOrSortedList,
pub links: BTreeSet<String>,
pub logging: Option<LoggingSettings>,
pub mac_address: Option<String>,
pub mem_limit: Option<StringOrNum>,
pub mem_reservation: Option<StringOrNum>,
pub mem_swappiness: Option<u8>,
pub memswap_limit: Option<StringOrNum>,
pub models: Option<ServiceModels>,
pub network_mode: Option<NetworkMode>,
pub networks: Option<ServiceNetworks>,
pub oom_kill_disable: Option<bool>,
pub oom_score_adj: Option<i32>,
pub pid: Option<String>,
pub pids_limit: Option<i64>,
pub platform: Option<String>,
pub ports: BTreeSet<Port>,
pub post_start: Vec<ServiceHook>,
pub pre_stop: Vec<ServiceHook>,
pub privileged: Option<bool>,
pub profiles: BTreeSet<String>,
pub provider: Option<Provider>,
pub pull_policy: Option<PullPolicy>,
pub pull_refresh_after: Option<String>,
pub read_only: Option<bool>,
pub restart: Option<Restart>,
pub runtime: Option<String>,
pub scale: Option<u64>,
pub secrets: BTreeSet<ServiceConfigOrSecret>,
pub security_opt: BTreeSet<String>,
pub shm_size: Option<StringOrNum>,
pub stdin_open: Option<bool>,
pub stop_grace_period: Option<String>,
pub stop_signal: Option<String>,
pub storage_opt: BTreeMap<String, Value>,
pub sysctls: ListOrMap,
pub tmpfs: Option<StringOrList>,
pub tty: Option<bool>,
pub ulimits: BTreeMap<String, Ulimit>,
pub use_api_socket: Option<bool>,
pub user: Option<String>,
pub userns_mode: Option<String>,
pub uts: Option<Uts>,
pub volumes: Vec<ServiceVolume>,
pub volumes_from: Vec<String>,
pub working_dir: Option<String>,
}Expand description
Defines a service for a Compose application.
See more: https://docs.docker.com/reference/compose-file/services/
Fields§
§extends: Option<Extends>extends lets you share common configurations among different files, or even different projects entirely.
See more: https://docs.docker.com/reference/compose-file/services/#extends
container_name: Option<String>A string that specifies a custom container name, rather than a name generated by default. Compose does not scale a service beyond one container if the Compose file specifies a container_name. Attempting to do so results in an error.
container_name follows the regex format of [a-zA-Z0-9][a-zA-Z0-9_.-]+
See more: https://docs.docker.com/reference/compose-file/services/#container_name
hostname: Option<String>A custom host name to use for the service container. It must be a valid RFC 1123 hostname.
image: Option<String>Specifies the image to start the container from. See more: https://docs.docker.com/reference/compose-file/services/#image
build_: Option<BuildStep>Specifies the build configuration for creating a container image from source, as defined in the Compose Build Specification.
depends_on: Option<DependsOn>With the depends_on attribute, you can control the order of service startup and shutdown. It is useful if services are closely coupled, and the startup sequence impacts the application’s functionality.
See more: https://docs.docker.com/reference/compose-file/services/#depends_on
command: Option<StringOrList>Overrides the default command declared by the container image, for example by Dockerfile’s CMD.
See more: https://docs.docker.com/reference/compose-file/services/#command
entrypoint: Option<StringOrList>Declares the default entrypoint for the service container. This overrides the ENTRYPOINT instruction from the service’s Dockerfile.
See more: https://docs.docker.com/reference/compose-file/services/#entrypoint
healthcheck: Option<Healthcheck>Declares a check that’s run to determine whether or not the service containers are “healthy”.
See more: https://docs.docker.com/reference/compose-file/services/#healthcheck
expose: BTreeSet<StringOrNum>Defines the (incoming) port or a range of ports that Compose exposes from the container. These ports must be accessible to linked services and should not be published to the host machine. Only the internal container ports can be specified.
See more: https://docs.docker.com/reference/compose-file/services/#expose
env_file: Option<Envfile>One or more files that contain environment variables to be passed to the containers.
See more: https://docs.docker.com/reference/compose-file/services/#env_file
environment: ListOrMapDefines environment variables set in the container. environment can use either an array or a map. Any boolean values; true, false, yes, no, should be enclosed in quotes to ensure they are not converted to True or False by the YAML parser.
See more: https://docs.docker.com/reference/compose-file/services/#environment
annotations: ListOrMapDefines annotations for the container. annotations can use either an array or a map.
attach: Option<bool>Requires: Docker Compose 2.20.0 and later
When attach is defined and set to false Compose does not collect service logs, until you explicitly request it to.
blkio_config: Option<BlkioSettings>Defines a set of configuration options to set block I/O limits for a service.
See more: https://docs.docker.com/reference/compose-file/services/#blkio_config
cap_add: BTreeSet<String>Specifies additional container capabilities as strings.
cap_drop: BTreeSet<String>Specifies container capabilities to drop as strings.
cgroup: Option<Cgroup>Requires: Docker Compose 2.15.0 and later
Specifies the cgroup namespace to join. When unset, it is the container runtime’s decision to select which cgroup namespace to use, if supported.
host: Runs the container in the Container runtime cgroup namespace. private: Runs the container in its own private cgroup namespace.
cgroup_parent: Option<String>Specifies an optional parent cgroup for the container.
configs: BTreeSet<ServiceConfigOrSecret>Lets services adapt their behaviour without the need to rebuild a Docker image.
See more: https://docs.docker.com/reference/compose-file/services/#configs
cpu_count: Option<StringOrNum>The number of usable CPUs for service container.
cpu_percent: Option<StringOrNum>The usable percentage of the available CPUs.
cpu_period: Option<StringOrNum>Configures CPU CFS (Completely Fair Scheduler) period when a platform is based on Linux kernel.
cpu_quota: Option<StringOrNum>Configures CPU CFS (Completely Fair Scheduler) quota when a platform is based on Linux kernel.
A service container’s relative CPU weight versus other containers.
cpu_rt_period: Option<StringOrNum>Configures CPU allocation parameters for platforms with support for real-time scheduler. It can be either an integer value using microseconds as unit or a duration.
cpu_rt_runtime: Option<StringOrNum>Configures CPU allocation parameters for platforms with support for real-time scheduler. It can be either an integer value using microseconds as unit or a duration.
cpus: Option<StringOrNum>The number of (potentially virtual) CPUs to allocate to service containers. This is a fractional number. 0.000 means no limit.
When set, cpus must be consistent with the cpus attribute in the Deploy Specification.
cpuset: Option<String>The explicit CPUs in which to permit execution. Can be a range 0-3 or a list 0,1
credential_spec: Option<CredentialSpec>Configures the credential spec for a managed service account.
See more: https://docs.docker.com/reference/compose-file/services/#credential_spec
deploy: Option<Deploy>Specifies the configuration for the deployment and lifecycle of services, as defined in the Compose Deploy Specification
develop: Option<DevelopmentSettings>Specifies the development configuration for maintaining a container in sync with source.
See more: https://docs.docker.com/reference/compose-file/develop
device_cgroup_rules: BTreeSet<String>A list of device cgroup rules for this container. The format is the same format the Linux kernel specifies in the Control Groups Device Whitelist Controller.
devices: BTreeSet<DeviceMapping>Defines a list of device mappings for created containers.
See more: https://docs.docker.com/reference/compose-file/services/#devices
dns: StringOrSortedListCustom DNS servers to set on the container network interface configuration. It can be a single value or a list.
dns_opt: BTreeSet<String>Custom DNS options to be passed to the container’s DNS resolver (/etc/resolv.conf file on Linux).
dns_search: StringOrSortedListCustom DNS search domains to set on container network interface configuration. It can be a single value or a list.
domainname: Option<String>A custom domain name to use for the service container. It must be a valid RFC 1123 hostname.
driver_opts: BTreeMap<String, StringOrNum>Requires: Docker Compose 2.27.1 and later
Specifies a list of options as key-value pairs to pass to the driver. These options are driver-dependent. Consult the network drivers documentation for more information.
external_links: BTreeSet<String>external_links link service containers to services managed outside of your Compose application. external_links define the name of an existing service to retrieve using the platform lookup mechanism.
extra_hosts: Option<ExtraHosts>Adds hostname mappings to the container network interface configuration (/etc/hosts for Linux).
See more: https://docs.docker.com/reference/compose-file/services/#extra_hosts
gpus: Option<Gpus>Requires: Docker Compose 2.30.0 and later
Specifies GPU devices to be allocated for container usage.
group_add: BTreeSet<StringOrNum>Additional groups, by name or number, which the user inside the container must be a member of.
See more: https://docs.docker.com/reference/compose-file/services/#group_add
init: Option<bool>Runs an init process (PID 1) inside the container that forwards signals and reaps processes. Set this option to true to enable this feature for the service.
The init binary that is used is platform specific.
ipc: Option<String>ipc configures the IPC isolation mode set by the service container.
shareable: Gives the container its own private IPC namespace, with a possibility to share it with other containers.
service:{name}: Makes the container join another container’s (shareable) IPC namespace.
See more: https://docs.docker.com/reference/compose-file/services/#ipc
isolation: Option<String>Container isolation technology to use. Supported values are platform-specific.
labels: ListOrMapAdd metadata to containers. You can use either an array or a map.
See more: https://docs.docker.com/reference/compose-file/services/#labels
label_file: StringOrSortedListRequires: Docker Compose 2.32.2 and later
The label_file attribute lets you load labels for a service from an external file or a list of files. This provides a convenient way to manage multiple labels without cluttering the Compose file. See more: https://docs.docker.com/reference/compose-file/services/#label_file
links: BTreeSet<String>Defines a network link to containers in another service. Either specify both the service name and a link alias (SERVICE:ALIAS), or just the service name.
See more: https://docs.docker.com/reference/compose-file/services/#links
logging: Option<LoggingSettings>Defines the logging configuration for the service.
See more: https://docs.docker.com/reference/compose-file/services/#logging
mac_address: Option<String>Sets a Mac address for the service container.
See more: https://docs.docker.com/reference/compose-file/services/#mac_address
mem_limit: Option<StringOrNum>Memory limit for the container. A string value can use suffix like ‘2g’ for 2 gigabytes.
When set, mem_limit must be consistent with the limits.memory attribute in the Deploy Specification.
mem_reservation: Option<StringOrNum>Configures a reservation on the amount of memory a container can allocate, set as a string expressing a byte value.
When set, mem_reservation must be consistent with the reservations.memory attribute in the Deploy Specification.
mem_swappiness: Option<u8>Defines as a percentage, a value between 0 and 100, for the host kernel to swap out anonymous memory pages used by a container.
0: Turns off anonymous page swapping. 100: Sets all anonymous pages as swappable.
The default value is platform specific.
memswap_limit: Option<StringOrNum>Defines the amount of memory the container is allowed to swap to disk.
See more: https://docs.docker.com/reference/compose-file/services/#memswap_limit
models: Option<ServiceModels>Requires: Docker Compose 2.38.0 and later
Defines which AI models the service should use at runtime. Each referenced model must be defined under the models top-level element.
See more: https://docs.docker.com/reference/compose-file/services/#models
network_mode: Option<NetworkMode>Sets a service container’s network mode.
none: Turns off all container networking. host: Gives the container raw access to the host’s network interface. service:{name}: Gives the container access to the specified container by referring to its service name. container:{name}: Gives the container access to the specified container by referring to its container ID.
See more: https://docs.docker.com/reference/compose-file/services/#network_mode
networks: Option<ServiceNetworks>The networks attribute defines the networks that service containers are attached to, referencing entries under the networks top-level element.
See more: https://docs.docker.com/reference/compose-file/services/#networks
oom_kill_disable: Option<bool>If oom_kill_disable is set, Compose configures the platform so it won’t kill the container in case of memory starvation.
oom_score_adj: Option<i32>Tunes the preference for containers to be killed by platform in case of memory starvation. Value must be within -1000,1000 range.
pid: Option<String>Sets the PID mode for container created by Compose. Supported values are platform specific.
pids_limit: Option<i64>Tune a container’s PIDs limit. Set to -1 for unlimited PIDs.
When set, pids_limit must be consistent with the pids attribute in the Deploy Specification.
platform: Option<String>The target platform the containers for the service run on. It uses the os[/arch[/variant]] syntax.
The values of os, arch, and variant must conform to the convention used by the OCI Image Spec.
Compose uses this attribute to determine which version of the image is pulled and/or on which platform the service’s build is performed.
ports: BTreeSet<Port>Used to define the port mappings between the host machine and the containers.
See more: https://docs.docker.com/reference/compose-file/services/#ports
post_start: Vec<ServiceHook>Requires: Docker Compose 2.30.0 and later
Defines a sequence of lifecycle hooks to run after a container has started. The exact timing of when the command is run is not guaranteed.
See more: https://docs.docker.com/reference/compose-file/services/#post_start
pre_stop: Vec<ServiceHook>Defines a sequence of lifecycle hooks to run before the container is stopped. These hooks won’t run if the container stops by itself or is terminated suddenly.
privileged: Option<bool>Configures the service container to run with elevated privileges. Support and actual impacts are platform specific.
profiles: BTreeSet<String>Defines a list of named profiles for the service to be enabled under. If unassigned, the service is always started but if assigned, it is only started if the profile is activated.
See more: https://docs.docker.com/reference/compose-file/services/#profiles
provider: Option<Provider>Defines a service that Compose won’t manage directly. Compose delegated the service lifecycle to a dedicated or third-party component.
See more: https://docs.docker.com/reference/compose-file/services/#provider
pull_policy: Option<PullPolicy>Defines the decisions Compose makes when it starts to pull images.
See more: https://docs.docker.com/reference/compose-file/services/#pull_policy
pull_refresh_after: Option<String>Time after which to refresh the image. Used with pull_policy=refresh.
read_only: Option<bool>Configures the service container to be created with a read-only filesystem.
restart: Option<Restart>Defines the policy that the platform applies on container termination.
See more: https://docs.docker.com/reference/compose-file/services/#restart
runtime: Option<String>Specifies which runtime to use for the service’s containers.
See more: https://docs.docker.com/reference/compose-file/services/#runtime
scale: Option<u64>Specifies the default number of containers to deploy for this service. When both are set, scale must be consistent with the replicas attribute in the Deploy Specification.
secrets: BTreeSet<ServiceConfigOrSecret>The secrets attribute grants access to sensitive data defined by the secrets top-level element on a per-service basis. Services can be granted access to multiple secrets.
See more: https://docs.docker.com/reference/compose-file/services/#secrets
security_opt: BTreeSet<String>Overrides the default labeling scheme for each container.
See more: https://docs.docker.com/reference/compose-file/services/#security_opt
shm_size: Option<StringOrNum>Size of /dev/shm. A string value can use suffix like ‘2g’ for 2 gigabytes.
stdin_open: Option<bool>Configures a service’s container to run with an allocated stdin. This is the same as running a container with the -i flag. For more information, see Keep stdin open.
stop_grace_period: Option<String>Specifies how long Compose must wait when attempting to stop a container if it doesn’t handle SIGTERM (or whichever stop signal has been specified with stop_signal), before sending SIGKILL. It’s specified as a duration.
Default value is 10 seconds for the container to exit before sending SIGKILL.
stop_signal: Option<String>The signal that Compose uses to stop the service containers. If unset containers are stopped by Compose by sending SIGTERM.
storage_opt: BTreeMap<String, Value>Defines storage driver options for a service.
sysctls: ListOrMapDefines kernel parameters to set in the container. sysctls can use either an array or a map.
See more: https://docs.docker.com/reference/compose-file/services/#sysctls
tmpfs: Option<StringOrList>Mounts a temporary file system inside the container. It can be a single value or a list.
See more: https://docs.docker.com/reference/compose-file/services/#tmpfs
tty: Option<bool>Configures a service’s container to run with a TTY. This is the same as running a container with the -t or –tty flag. For more information, see Allocate a pseudo-TTY.
ulimits: BTreeMap<String, Ulimit>Overrides the default ulimits for a container. It’s specified either as an integer for a single limit or as mapping for soft/hard limits.
See more: https://docs.docker.com/reference/compose-file/services/#ulimits
use_api_socket: Option<bool>When use_api_socket is set, the container is able to interact with the underlying container engine through the API socket. Your credentials are mounted inside the container so the container acts as a pure delegate for your commands relating to the container engine. Typically, commands ran by container can pull and push to your registry.
user: Option<String>Overrides the user used to run the container process. The default is set by the image, for example Dockerfile USER. If it’s not set, then root.
userns_mode: Option<String>Sets the user namespace for the service. Supported values are platform specific and may depend on platform configuration.
uts: Option<Uts>/// Configures the UTS namespace mode set for the service container. When unspecified it is the runtime’s decision to assign a UTS namespace, if supported.
volumes: Vec<ServiceVolume>The volumes attribute define mount host paths or named volumes that are accessible by service containers.
See more: https://docs.docker.com/reference/compose-file/services/#volumes
volumes_from: Vec<String>Mounts all of the volumes from another service or container. You can optionally specify read-only access ro or read-write rw. If no access level is specified, then read-write access is used.
You can also mount volumes from a container that is not managed by Compose by using the container: prefix.
working_dir: Option<String>Overrides the container’s working directory which is specified by the image, for example Dockerfile’s WORKDIR.