docker-compose yaml - option to pass the 'ulimit' parameters 'rtprio' and 'memlock'
Asked Answered
M

2

8

I can't find the option in the docker-compose.yaml to pass the parameters the following 'docker' parameters:

--ulimit rtprio=95 --ulimit memlock=-1

In other words, I wish to wrap the following command with docker-compose:

docker run --rm -it --network host --ulimit rtprio=95 --ulimit memlock=-1 --name my_proj image/my_image bash

Mellon answered 27/1, 2019 at 10:50 Comment(0)
N
17

There's a per-service dictionary called ulimits:.

version: '3'
services:
  my_proj:
    image: image/my_image
    ulimits:
      rtprio: 95
      memlock: -1
    ...

Note that Docker Compose works better with non-interactive services that stay running; I would use it to launch your service proper and not necessarily to get an interactive shell in a temporary container.

Nephoscope answered 27/1, 2019 at 11:53 Comment(1)
I used 'bash' just for the example. Thanks for the solution!Mellon
I
-2

ulimits is depricated

Note: This replaces the older resource constraint options for non swarm mode in Compose files prior to version 3 (cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit, mem_swappiness), as described in Upgrading version 2.x to 3.x.

(Source: docker.com/compose/compose-file/#resources)

deploy:
  resources:
    limits:
      memory: 8g
    reservations:
      memory: 4g
Invulnerable answered 3/4, 2019 at 14:34 Comment(3)
Not true. ulimits is still used in version 3. docs.docker.com/compose/compose-file/#ulimitsConiah
above is correct, also there's no "limit" option for core dump sizeMoeller
links are outdatedMargerymarget

© 2022 - 2024 — McMap. All rights reserved.