Description
This is very similar to the issue in #2730, when using environment variable substitution in a compose file to set the number of GPUs assigned to a container, the following error occurs:
error decoding 'Deploy.Resources.Reservations.devices[0]': invalid string value for 'count' (the only value allowed is 'all')
Steps To Reproduce
Take the following docker-compose.yml
version: "3.8"
services:
my-service:
image: hello-world
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: ${GPUS_PER_SERVER}
capabilities: [gpu]
This command will fail:
$ export GPUS_PER_SERVER=1
$ docker compose up
1 error(s) decoding:
* error decoding 'Deploy.Resources.Reservations.devices[0]': invalid string value for 'count' (the only value allowed is 'all')
However, the following will succeed:
$ export GPUS_PER_SERVER="all"
$ docker compose up
[+] Running 2/2
✔ Network local_default Created
✔ Container my-service-1 Created
Attaching to my-service-1
my-service-1 | Hello from Docker!
Compose Version
Docker Compose version v2.17.2
Docker Environment
No response
Anything else?
No response