How to set docker compose pids limit?

Hello ,

How to set docker compose pids limit?

Docker-ce 20.10.17
Docker Compose versiyon 2.6.0

Note that this have been removed in docker-compose 3

… and was recently reintroduced in the current compose schema, which merges the v2 and v3 synatax and does not even require the version to be provided anymore. Though it requires at least docker-compose v1.29.x, or the docker cli-plugin (not sure which version though, just use the recent 2.7.x version and you should be good)

pids_limit is marked deprecated and replaced by deploy.reservations.pids according the docs.

Oddly, the example does not match the flattend key hirarchy from obove

    image: awesome/webapp
          cpus: '0.50'
          memory: 50M
          pids: 1
          cpus: '0.25'
          memory: 20M

This works for docker compose and docker stack deploy deployments. I have no idea if it will work with the latest docker-compose version, or will simply ignore the elements. I haven’t tested it,

Of course the unneeded elements like cpus:, memory: and even the reservations:element can be removed if not needed.