Skip to content

1.27.2 does not allow reservations.cpu to be string #7766

@ryanoolala

Description

@ryanoolala

Description of the issue

docker-compose reservation cpu requires number instead of string, resulting in error when running docker-compose up with the following yaml, as extracted from the documentation

...
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 50M
        reservations:
          cpus: '0.25'
          memory: 20M

This error happens in all 1.27.0-1.27.2 releases. Downgrading to 1.26.2 fixes this

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.27.2, build unknown
docker-py version: 4.2.2
CPython version: 3.8.5
OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020

Output of docker version

Client:
 Version:           19.03.12-ce
 API version:       1.40
 Go version:        go1.14.5
 Git commit:        48a66213fe
 Built:             Sat Jul 18 01:33:21 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.12-ce
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.14.5
  Git commit:       48a66213fe
  Built:            Sat Jul 18 01:32:59 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.4.m
  GitCommit:        d76c121f76a5fc8a462dc64594aea72fe18e1178.m
 runc:
  Version:          1.0.0-rc91
  GitCommit:        24a3cf88a7ae5f4995f6750654c0e2ca61ef4bb2
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker-compose config
(Make sure to add the relevant -f and other flags)

services:
  redis:
    deploy:
      resources:
        limits:
          cpus: '0.50'
          memory: 50M
        reservations:
          cpus: '0.25'
          memory: 20M
    image: redis:alpine
version: '3.8'

Steps to reproduce the issue

  1. Upgrade to 1.27.x
  2. set reservations.cpu to string '1'
  3. docker-compose up

Observed result

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.redis.deploy.resources.reservations.cpus contains an invalid type, it should be a string

Expected result

Redis to start succcessfully

Stacktrace / full error message

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.redis.deploy.resources.reservations.cpus contains an invalid type, it should be a string

Additional information

OS version / distribution, docker-compose install method, etc.
Arch linux
MacOS

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions