For more detailed information about job options and behavior, see the [Docker CLI documentation](/reference/cli/docker/service/create.md#running-as-a-job)
### `placement`
`placement` specifies constraints and preferences for the platform to select a physical node to run service containers.
#### `constraints`
`constraints` defines a required property the platform's node must fulfill to run the service container. For a further example, see the [CLI reference docs](/reference/cli/docker/service/create.md#constraint).
```yml
deploy:
placement:
constraints:
- disktype=ssd
```
#### `preferences`
`preferences` defines a strategy (currently `spread` is the only supported strategy) to spread tasks evenly
over the values of the datacenter node label. For a further example, see the [CLI reference docs](/reference/cli/docker/service/create.md#placement-pref)
```yml
deploy:
placement:
preferences:
- spread: node.labels.zone
```
### `replicas`
If the service is `replicated` (which is the default), `replicas` specifies the number of containers that should be
running at any given time.
```yml
services:
frontend:
image: example/webapp
deploy:
mode: replicated
replicas: 6
```
### `resources`
`resources` configures physical resource constraints for container to run on platform. Those constraints can be configured
as:
- `limits`: The platform must prevent the container to allocate more.
- `reservations`: The platform must guarantee the container can allocate at least the configured amount.
```yml
services:
frontend:
image: example/webapp
deploy:
resources:
limits:
cpus: '0.50'
memory: 50M
pids: 1
reservations:
cpus: '0.25'
memory: 20M
```
#### `cpus`
`cpus` configures a limit or reservation for how much of the available CPU resources, as number of cores, a container can use.
#### `memory`
`memory` configures a limit or reservation on the amount of memory a container can allocate, set as a string expressing a [byte value](extension.md#specifying-byte-values).
#### `pids`
`pids` tunes a container’s PIDs limit, set as an integer.
#### `devices`
`devices` configures reservations of the devices a container can use. It contains a list of reservations, each set as an object with the following parameters: `capabilities`, `driver`, `count`, `device_ids` and `options`.
Devices are reserved using a list of capabilities, making `capabilities` the only required field. A device must satisfy all the requested capabilities for a successful reservation.
##### `capabilities`
`capabilities` are set as a list of strings, expressing both generic and driver specific capabilities.
The following generic capabilities are recognized today:
- `gpu`: Graphics accelerator
- `tpu`: AI accelerator
To avoid name clashes, driver specific capabilities must be prefixed with the driver name.
For example, reserving an NVIDIA CUDA-enabled accelerator might look like this:
```yml
deploy:
resources:
reservations:
devices:
- capabilities: ["nvidia-compute"]
```
##### `driver`
A different driver for the reserved device(s) can be requested using `driver` field. The value is specified as a string.
```yml
deploy:
resources:
reservations:
devices:
- capabilities: ["nvidia-compute"]
driver: nvidia
```
##### `count`
If `count` is set to `all` or not specified, Compose reserves all devices that satisfy the requested capabilities. Otherwise, Compose reserves at least the number of devices specified. The value is specified as an integer.
```yml
deploy:
resources:
reservations:
devices:
- capabilities: ["tpu"]
count: 2
```
`count` and `device_ids` fields are exclusive. Compose returns an error if both are specified.
##### `device_ids`
If `device_ids` is set, Compose reserves devices with the specified IDs provided they satisfy the requested capabilities. The value is specified as a list of strings.