docker / docker/cli

[BUG] 26.0.1 does not allow resources.limits.cpu to be a number

Open
#5,009 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/stack impact/compose-file kind/bug status/0-triage
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

We used docker-ce 26.0.0 before (former debian 11 default package), and after the upgrade to 26.0.1 (current debian 11 stable package as of last night) our stack deployments fail with something like "services.agent.deploy.resources.limits.cpus must be a string"

We usually do something like docker compose config | .. | docker stack deploy, this worked with docker 26.0.0 and docker compose 2.25.0 but does not work with docker 26.0.1 and docker compose 2.26.1 anymore.

My initial thought was that it was related to docker compose, so I opened this issue: https://github.com/docker/compose/issues/11721
As it seems not to be related with compose, I was pointed to this repository.

I checked the compose spec and it still seems to allow "number", "string": https://github.com/compose-spec/compose-spec/blob/master/schema/compose-spec.json#L519

Reproduce

config:

version: '3.8'
services:
  agent:
    deploy:
      mode: global
      resources:
        limits:
          cpus: 0.5
          memory: "268435456"
        reservations:
          cpus: 0.1
          memory: "67108864"
      placement:
        constraints:
          - node.platform.os == linux
    image: portainer/agent:2.20.1
    networks:
      master_agent_network: null
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
        bind:
          create_host_path: true
      - type: bind
        source: /var/lib/docker/volumes
        target: /var/lib/docker/volumes
        bind:
          create_host_path: true

Trying to deploy this via docker stack deploy will result in "services.agent.deploy.resources.limits.cpus must be a string" and the deployment will fail.

Expected behavior

Using docker stack deploy with the config above should work

docker version
Client: Docker Engine - Community
 Version:           26.0.1
 API version:       1.45
 Go version:        go1.21.9
 Git commit:        d260a54
 Built:             Thu Apr 11 10:53:52 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          26.0.1
  API version:      1.45 (minimum version 1.24)
  Go version:       go1.21.9
  Git commit:       60b9add
  Built:            Thu Apr 11 10:53:52 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.31
  GitCommit:        e377cd56a71523140ca6ae87e30244719194a521
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker info
Client: Docker Engine - Community
 Version:    26.0.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.13.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.26.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 18
  Running: 17
  Paused: 0
  Stopped: 1
 Images: 37
 Server Version: 26.0.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: active
  NodeID: XXX
  Is Manager: true
  ClusterID: XXX
  Managers: 3
  Nodes: 5
  Default Address Pool: 10.0.0.0/8  
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: xxx
  Manager Addresses:
   xxx:2377
   yyy:2377
   zzz:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e377cd56a71523140ca6ae87e30244719194a521
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.10.0-28-amd64
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.62GiB
 Name: XXX
 ID: XXX
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
Additional Info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the docker stack deploy entry point and reproduce the failure with the supplied Compose configuration on Docker 26.0.1. Compare the behavior with 26.0.0 and verify that numeric cpus values deploy successfully while string values continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.