0

I have installed docker swarm on an ubuntu machine on aws. After that, I have spinned up few services on that. After few services the machine got hang and unable to connect. Everytime, I need to restart the machine and the containers are getting created again because of this. Is there any way to restrict the docker swarm services to use only 50% percent of CPU or memory so that my main machine won't get hung up.?

And also, when I restart the machine, the services are creating new containers, any option to use the existing ones only without creating new ones.

6
  • Looks like you don't specify resource constraints: docs.docker.com/compose/compose-file/compose-file-v3/#resources. You definitly don't want to run productive workload without ressource contraints.
    – Metin
    Dec 29, 2020 at 19:18
  • I am using docker service command to create a swarm service of containers.Like this. How to configure here.? docker service create --name mariadb_17 -p target=3306 -e MYSQL_DATABASE=mydb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:latest
    – uday kiran
    Jan 1, 2021 at 8:28
  • Did you check docs.docker.com/engine/reference/commandline/service_create ? --reserve-memory, --limit-memory and --reserve-cpu, --limit-cpu seem like the options you want to use. Also: you should start using compose files, as they will make your life easier: you can version control your compose file and get repeatability and full documentation of what you run for free on top.
    – Metin
    Jan 1, 2021 at 12:15
  • Can I set docker swarm as a whole to use only half of the memory and cpu instead of individual entries. As if I set 2 GB to a service and 2 GB to another on a 4GB machine, it would finish all of that.
    – uday kiran
    Jan 1, 2021 at 12:38
  • Hint: if something is missing in the documentation, it is usaly not a sign that people forget to put it into the documentation... wouldn't you agree?
    – Metin
    Jan 1, 2021 at 18:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.