Docker Swarm services: declare a desired state and let the swarm keep it
Answer: Swarm services use a declarative model: you define the desired state, and Docker maintains it.
What the desired state includes
The state includes the image name and tag the service containers should run.
It also includes how many containers participate in the service.
It can record whether any ports are exposed to clients outside the swarm.
It can say whether the service should start automatically when Docker starts.
Creating a simple service
A service with one replica and no extra settings needs only the image name.
Restart behavior, such as a rolling restart, can be part of the declared state.
You can also describe characteristics of the nodes where the service can run.
Those characteristics include resource constraints and placement preferences.
See also
Claims
- id: C1 claim: Swarm services use a declarative model. source: S1 evidence: "Swarm services use a declarative model"
- id: C2 claim: You define the desired state of the service and rely on Docker to maintain this state. source: S1 evidence: "rely upon Docker to maintain this state"
- id: C3 claim: The state includes the image name and tag the service containers should run. source: S2 evidence: "The image name and tag the service containers should run"
- id: C4 claim: A simple single-replica service needs only the image name. source: S2 evidence: "you only need to supply the image name"
Sources
- [S1] Deploy services to a swarm. Docker, Inc.. https://docs.docker.com/engine/swarm/services/ . License: Apache License 2.0. Accessed 2026-11-26.
- [S2] Deploy services to a swarm (source). Docker, Inc.. https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/swarm/services.md . License: Apache License 2.0. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Deploy services to a swarm; Docker, Inc., Deploy services to a swarm (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Docker, Inc., Deploy services to a swarm; Docker, Inc., Deploy services to a swarm (source). Apache-2.0 (https://raw.githubusercontent.com/docker/docs/main/LICENSE). Copyright Docker, Inc.
Cite this
iinventedlight. 2026. "Docker Swarm services: declare a desired state and let the swarm keep it." iinventedlight Library, iil:note:aphcfn83, version of 2026-11-26. https://iinventedlight.com/library/notes/docker-swarm-services/. License: CC-BY-4.0.
@misc{iil_note_aphcfn83,
author = {{iinventedlight}},
title = {{Docker Swarm services: declare a desired state and let the swarm keep it}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/docker-swarm-services/},
note = {Permanent ID iil:note:aphcfn83. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- docker-swarm-services.schema.json (schema; CC-BY-4.0)
- docker-swarm-services.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/docker-swarm-services.md.