drmxxxxx
(Matthias Brauchle)
November 21, 2023, 4:00pm
1
Hello all,
for an swarm with elasticsearch, I need to disable swapping in the docker container.
When I read this Documentation , I need to configure the memswap_limit
with the same number as the deploy.limits.memory
.
But this did not work in a compose file, which is used for a swarm.
Example docker-compose.yml:
version: "3.8"
services:
elasticsearch:
memswap_limit: 2G
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.1-amd64
logging:
driver: json-file
options:
max-file: '10'
max-size: 20m
environment:
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
volumes:
- /path/to/folder:/path/to/folder
ports:
- 9200:9200
- 9300:9300
deploy:
mode: global
resources:
limits:
memory: 2G
networks:
- net
When I issue the command docker stack deploy -f docker-compose.yml stackname
I get an error, that the memswap_limit
is not supported.
How would I now disable swapping in a swarm container configuration?
Thanks!
M
rimelek
(Ákos Takács)
November 21, 2023, 7:58pm
2
You read the compose specification for Docker Compose v2, but it seems Docker Swarm doesn’t support this option.
opened 07:16PM - 28 Aug 17 UTC
area/swarm
**Description**
I'm using docker swarm mode to start a service with
```
… --limit-memory 2GB \
```
and the container then used 2GB plus abrou 4GB SWAP.
I was looking for a way to limit or remove the SWAP capabilities of the service but without any luck in the ```docker service create``` documentation.
As far as I can see, "normal" docker containers can be limited with ```--memory-swap```.
How can we remove the SWAP space for services in swarm mode?
**Steps to reproduce the issue:**
1. Start a service and limit it's memory
2. Make the task consume more memory than the limit
**Output of `docker version`:**
```
17.06
```
**Additional environment details (AWS, VirtualBox, physical, etc.):**
Ubuntu 16.04
This is an old issue, but still open and docker service create
doesn’t have swap limit option either, only memory limit.
drmxxxxx
(Matthias Brauchle)
November 22, 2023, 1:32pm
3
Thanks for your answer!
This is pretty bad, since I would need this feature.
bluepuma77
(Bluepuma77)
November 23, 2023, 7:47am
4
I thought it’s bad how slooowly Docker Swarm is moving forward, but even Docker itself has some very basic things that seemingly don’t get fixed for years, even swap for regular service (link ).
There’s an “epic” with a whole list of missing pieces (link), we should get some summer interns to finally fix those
You could try to create an issue for compose spec (link ), it might finally get a simple implementation if it’s accepted there. But it’s just an idea, I have no proof