swarmkit icon indicating copy to clipboard operation
swarmkit copied to clipboard

How can I create a container without replica concept in swarm cluster

Open JiangJungle opened this issue 2 years ago • 4 comments

In the Swarm cluster, I can only create a container with the concept of replica, which is called service, or use docker run to start a local container.

I want to create a container in the swarm cluster. This container can't expand replicas and can be dispatched to any node in the cluster. The docker run command can only start the container locally, and the swarm service can change the number of copies at will. These are not what I want.

Please tell me what I should do, thank you!

JiangJungle avatar Sep 04 '22 08:09 JiangJungle

What's wrong with having replica=1? Swarm wouldn't just increase that number.

bluepuma77 avatar Sep 08 '22 06:09 bluepuma77

What's wrong with having replica=1? Swarm wouldn't just increase that number.

I can only have one container, otherwise my application cluster will have problems. I must prevent the swarm service replica from being changed。

JiangJungle avatar Sep 08 '22 12:09 JiangJungle

If this is really important to you, I suggest looking into solutions like https://github.com/ybrs/single-beat and handling this on the application side

s4ke avatar Sep 09 '22 19:09 s4ke

@JiangJungle :

replica = 1 and max_replicas_per_node = 1

and also make sure you use stop-first update order

  • https://docs.docker.com/engine/reference/commandline/service_create/#replicas-max-per-node
  • https://docs.docker.com/engine/reference/commandline/service_update/
  • https://docs.docker.com/compose/compose-file/deploy/#update_config

If you are satisfied with the answers, please close the issue. You might also fix this application wise like it was mentioned above.

ieugen avatar Jan 24 '24 11:01 ieugen