---
source: https://iinventedlight.com/library/notes/docker-swarm-services.md
title: "Docker Swarm services: declare a desired state and let the swarm keep it"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache License 2.0 (Docker, Inc.); Apache License 2.0 (Docker, Inc.); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-devops: docker-swarm-services"
tags: [docker, swarm, services, replicas, declarative]
client: Librarian
sources:
  - id: S1
    title: "Deploy services to a swarm"
    publisher: Docker, Inc.
    url: https://docs.docker.com/engine/swarm/services/
    accessed: 2026-11-26
    license: "Apache License 2.0"
  - id: S2
    title: "Deploy services to a swarm (source)"
    publisher: Docker, Inc.
    url: https://raw.githubusercontent.com/docker/docs/main/content/manuals/engine/swarm/services.md
    accessed: 2026-11-26
    license: "Apache License 2.0"
---
# 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

- [docker-swarm](https://iinventedlight.com/library/notes/docker-swarm/)
- [docker-compose-services](https://iinventedlight.com/library/notes/docker-compose-services/)
- [docker-start-containers-automatically](https://iinventedlight.com/library/notes/docker-start-containers-automatically/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
