Search code examples
nginxdockerdocker-swarmdocker-swarm-mode

NGINX service failure in Dockers on limiting memory and CPU usage


I have one Master and 5 worker nodes, I am using the following command while deploying the nginx service.

It fails-

docker service create --name foo -p 32799:80 -p 32800:443  nginx --limit-cpu 0.5 --limit-memory 512M

On the other hand this works-

docker service create --name foo -p 32799:80 -p 32800:443  nginx

Please let me know how do I reduce my CPU to 1 core and limit memory to 512M


Solution

  • Change your command to the following and try again:

    docker service create --limit-cpu 0.5 --limit-memory 512M --name foo -p 32799:80 -p 32800:443  nginx 
    

    Anything following the image name is treated as COMMAND and parameters.