Docker Community Forums

Share and learn in the Docker community.

Trouble with addding cpu and memory limit to docker services

docker

(Rajinder Singh) #1

we are using

sudo docker --version
Docker version 17.09.0-ce, build afdb6d4

We are using docker services.
OS is Ubuntu 16.04.
We have 3 worker nodes with 28 GB RAM and 4 Cores each.

We have a hand full of services running. We want to put memory and cpu limits on our services.
I removed an existing service and added --limit-cpu 1 --limit-memory 1g

  sudo docker service create --name $servicename --constraint "node.role==worker" --limit-cpu $limitcpu --limit-memory $limitmemory  --with-registry-auth --replicas 3  $envnew --network $networkname  --publish 80:8888 --detach=false $serviceimagename:$version

Once we run this command the deployment never finishes.
sudo docker service ls shows the service but it also shows 0/3 replicas.

I have changed the cpu and memory values but nothing seems to make a difference.

I have looked at service logs and I don’t see anything that shows an issue

journalctl -u docker -n -f . shows no errors

I picked a redis image from docker hub. I used the exact same command to create that service. it worked.

sudo docker service create --name redis1 --env-add --constraint “node.role==worker” --constraint-add “cpus==2” --constraint-add “memory==50m” --replicas 3 --network swarm-network redis
This service converges.

I am trying to understand why adding cpu and memory limits on our custom service prevents it from converging.

Which logs should I look at?
How can I debug this issue?