moby / swarmkit

A toolkit for orchestrating distributed systems at any scale. It includes primitives for node discovery, raft-based consensus, task scheduling and more.
Apache License 2.0
3.38k stars 616 forks source link

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

Open JiangJungle opened 2 years ago

JiangJungle commented 2 years ago

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!

bluepuma77 commented 2 years ago

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

JiangJungle commented 2 years ago

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。

s4ke commented 2 years ago

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

ieugen commented 10 months ago

@JiangJungle :

replica = 1 and max_replicas_per_node = 1

and also make sure you use stop-first update order

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