Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Resources reservations has no effect in v3 for non swarm #10046

Closed
FireEmerald opened this issue Dec 6, 2022 · 1 comment
Closed

[BUG] Resources reservations has no effect in v3 for non swarm #10046

FireEmerald opened this issue Dec 6, 2022 · 1 comment

Comments

@FireEmerald
Copy link

FireEmerald commented Dec 6, 2022

Description

This issue belongs to the NON SWARM mode.

As per current definition the deploy section of the v3 compose file shall only have a effect when using swarm, expect for resources:

The following sub-options only takes effect when deploying to a swarm with docker stack deploy, and is ignored by docker-compose up and docker-compose run, except for resources.

Which works for setting deploy: resources: limits: memory: 100M, even when not in swarm mode nor using the --compatibility flag. The inspect command shows correct "Memory": 104857600.

BUT which does not work is setting deploy: resources: reservations: memory: 100M - it has no effect. Looked up via docker inspect containerA shows:

[
  {
    "HostConfig": {
      "MemoryReservation": 0,
  }
]

What does work is setting mem_reservation on the service level but the official Compose Specification says about:

mem_reservation DEPRECATED: use deploy.reservations.memory.

Steps To Reproduce

See description to reproduce.

Compose Version

Docker Compose version v2.12.2

Docker Environment

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.12.2)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 3
  Running: 1
  Paused: 0
  Stopped: 2
 Images: 4
 Server Version: 20.10.21
 Storage Driver: btrfs
  Build Version: Btrfs v5.10.1
  Library Version: 102
 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 logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.0-15-cloud-amd64
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.773GiB
 Name: monitoringlinux-dev
 ID: TQFM:TIMQ:XNFZ:MMPO:J2BM:6XG4:56KA:CFBA:MTD7:H3BI:G65U:6IXL
 Docker Root Dir: /opt/docker-data
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@FireEmerald FireEmerald changed the title [BUG] Resources reservations does not work in v3 [BUG] Resources reservations has no effect in v3 for non swarm Dec 6, 2022
@laurazard laurazard self-assigned this Dec 6, 2022
@laurazard
Copy link
Member

laurazard commented Dec 6, 2022

Hi @FireEmerald, thanks for your report.

This was fixed in #9947, which was included in Compose versionv2.13.0.

Using that (or a later version) it works as expected. With the Compose file:

services:
  a:
    image: alpine
    command: top
    deploy:
      resources:
        reservations:
          memory: 100M

and then running docker inspect <container_name> I see:

[...]
"MemoryReservation": 104857600,
[...]

Please download a newer version of Compose, or update Docker Desktop to get a newer version to get this working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants