instruction: Design a zero-downtime deployment strategy for Apply rolling updates to a service | Docker Docs Get started Guides Manuals Reference Ask&nbsp;AI { ...
output: Apply rolling updates to a service | Docker Docs Get started Guides Manuals Reference Ask&nbsp;AI { switch(e.key) { case 'k': if (e.metaKey || e.ctrlKey) { e.preventDefault(); $el.focus(); } break; } }" tabindex=0> Start typing to search or try Ask AI . Contact support { localStorage.setItem('theme-preference', value); document.firstElementChild.className = value; })" @click="theme = (theme === 'dark' ? 'light' : 'dark')"> { const container = $el; // The div with overflow const item = document.getElementById('sidebar-current-page') if (item) { const containerTop = container.scrollTop; const containerBottom = containerTop + container.clientHeight; const itemTop = item.offsetTop - container.offsetTop; const itemBottom = itemTop + item.offsetHeight; // Scroll only if the item is out of view if (itemBottom > containerBottom - 200) { container.scrollTop = itemTop - (container.clientHeight / 2 - item.offsetHeight / 2); } } })" class="bg-background-toc dark:bg-background-toc fixed top-0 z-40 hidden h-screen w-full flex-none overflow-x-hidden overflow-y-auto md:sticky md:top-16 md:z-auto md:block md:h-[calc(100vh-64px)] md:w-[320px]" :class="{ 'hidden': ! $store.showSidebar }"> Back Ask&nbsp;AI { switch(e.key) { case 'k': if (e.metaKey || e.ctrlKey) { e.preventDefault(); $el.focus(); } break; } }" tabindex=0> Start typing to search or try Ask AI . Contact support { localStorage.setItem('theme-preference', value); document.firstElementChild.className = value; })" @click="theme = (theme === 'dark' ? 'light' : 'dark')"> Manuals Get started Guides Reference Open source Docker Engine Install Ubuntu Debian RHEL Fedora Raspberry Pi OS (32-bit) CentOS SLES (s390x) Binaries Post-installation steps Storage Volumes Bind mounts tmpfs mounts Storage drivers Select a storage driver BTRFS storage driver Device Mapper storage driver (deprecated) OverlayFS storage driver VFS storage driver windowsfilter storage driver ZFS storage driver containerd image store Networking Packet filtering and firewalls Network drivers Bridge network driver Host network driver IPvlan network driver Macvlan network driver None network driver Overlay network driver Tutorials Networking using a macvlan network Networking using the host network Networking with overlay networks Networking with standalone containers CA certificates Legacy container links Containers Start containers automatically Run multiple processes in a container Resource constraints Runtime metrics Running containers CLI Completion Proxy configuration Filter commands Format command and log output OpenTelemetry for the Docker CLI Daemon Start the daemon Use IPv6 networking Daemon proxy configuration Live restore Alternative container runtimes Collect Docker metrics with Prometheus Configure remote access for Docker daemon Read the daemon logs Troubleshooting the Docker daemon Manage resources Docker contexts Docker object labels Prune unused Docker objects Logs and metrics Configure logging drivers Customize log driver output Logging drivers Amazon CloudWatch Logs logging driver ETW logging driver Fluentd logging driver Google Cloud Logging driver Graylog Extended Format logging driver Journald logging driver JSON File logging driver Local file logging driver Splunk logging driver Syslog logging driver Use a logging driver plugin Use docker logs with remote logging drivers Security Rootless mode Antivirus software and Docker AppArmor security profiles for Docker Content trust in Docker Automation with content trust Delegations for content trust Deploy Notary Server with Compose Manage keys for content trust Play in a content trust sandbox Docker security non-events Isolate containers with a user namespace Protect the Docker daemon socket Seccomp security profiles for Docker Verify repository client with certificates Swarm mode Administer and maintain a swarm of Docker Engines Deploy a stack to a swarm Deploy services to a swarm Getting started with Swarm mode Create a swarm Add nodes to the swarm Deploy a service to the swarm Inspect a service on the swarm Scale the service in the swarm Delete the service running on the swarm Apply rolling updates to a service Drain a node on the swarm How swarm works How nodes work How services work Manage swarm security with public key infrastructure (PKI) Swarm task states Join nodes to a swarm Lock your swarm to protect its encryption key Manage nodes in a swarm Manage sensitive data with Docker secrets Manage swarm service networks Raft consensus in swarm mode Run Docker Engine in swarm mode Store configuration data using Docker Configs Swarm mode key concepts Use Swarm mode routing mesh Deprecated features Docker Engine plugins Access authorization plugin Docker log driver plugins Docker network driver plugins Docker Plugin API Docker volume plugins Plugin Config Version 1 of Plugin V2 Use Docker Engine plugins Release notes Engine v28 Engine v27 Engine v26.1 Engine v26.0 Engine v25.0 Engine v24.0 Engine v23.0 Engine v20.10 Engine v19.03 Engine v18.09 Engine v18.06 Engine v18.05 Engine v18.04 Engine v18.03 Engine v18.02 Engine v18.01 Engine v17.12 Engine v17.11 Engine v17.10 Engine v17.09 Engine v17.07 Engine v17.06 Engine v17.05 Engine v17.04 Engine v17.03 Prior releases Docker Build Core concepts Docker Build Overview Dockerfile overview Build context Building Multi-stage Variables Secrets Multi-platform Export binaries Container Device Interface (CDI) Best practices Base images Build checks New Builders Build drivers Docker container driver Docker driver Kubernetes driver Remote driver Manage builders Bake Introduction Targets Inheritance Variables Expressions Functions Matrix targets Contexts Bake file reference Bake standard library functions Building with Bake from a Compose file Overriding configurations Remote Bake file definition Cache Build cache invalidation Build garbage collection Cache storage backends Amazon S3 cache Azure Blob Storage cache GitHub Actions cache Inline cache Local cache Registry cache Optimize cache usage in builds CI GitHub Actions Annotations Attestations Build checks Build secrets Build summary BuildKit configuration Cache management Copy image between registries Export to Docker Local registry Multi-platform image Named contexts Push to multiple registries Reproducible builds Share image between jobs Tags and labels Test before push Update Docker Hub description Metadata Annotations Build attestations Image attestation storage Provenance attestations SBOM attestations SLSA definitions Exporters Image and registry exporters Local and tar exporters OCI and Docker exporters BuildKit buildkitd.toml Configure BuildKit Custom Dockerfile syntax Dockerfile release notes Debugging OpenTelemetry support Build release notes Docker Compose Introduction to Compose How Compose works Why use Compose? History and development Install Plugin Standalone Uninstall Quickstart How-tos Specify a project name Use lifecycle hooks Use service profiles Control startup order Use environment variables Set environment variables Environment variables precedence Pre-defined environment variables Interpolation Best practices Build dependent images Use Compose Watch Secrets in Compose Networking Use multiple Compose files Merge Extend Include Enable GPU support Use Compose in production OCI artifact applications New Use provider services New Compose Bridge Usage Customize Support and feedback FAQs Give feedback Sample apps Releases Release notes Migrate to Compose v2 MCP Gateway Testcontainers AI Ask Gordon Beta Model Context Protocol (MCP) Built-in tools in Gordon Configure MCP servers with YAML Model Runner Beta Get started with DMR DMR REST API DMR examples MCP Catalog and Toolkit Beta MCP Catalog MCP Toolkit Hub MCP server AI and Docker Compose Use AI models in Compose New Products Docker Desktop Setup Install Mac Mac permission requirements Windows Windows permission requirements Linux Ubuntu Debian Fedora Arch RHEL VM or VDI environments Sign in Allowlist Explore Docker Desktop Containers Images Volumes Builds Resource Saver mode Pause Docker Desktop Features and capabilities Networking GPU support USB/IP support Deploy on Kubernetes Synchronized file shares containerd image store Wasm workloads Beta Docker Desktop CLI Virtual Machine Manager WSL Best practices Custom kernels on WSL Use WSL Settings and maintenance Change settings Backup and restore data Troubleshoot and support Troubleshoot and diagnose Common topics Known issues Get support for Docker Desktop FAQs General Mac Windows Linux Releases Give feedback Uninstall Fix startup issue for Mac Release notes Docker Hardened Images New Quickstart About Hardened images Image types Image testing Responsibility overview Features Flexibility Continuous patching Enterprise support Hardened, secure images Seamless integration How-tos Explore images Mirror an image Customize an image Use an image Verify an image Manage images Scan an image Enforce image usage Migrate an app Debug a container Core concepts Attestations CIS Benchmark Code signing CVEs Distroless images FIPS glibc and musl Hardening Image digests Image provenance Immutability SBOMs SLSA Software Supply Chain Security SSDLC STIG VEX Troubleshoot Docker Offload Beta Quickstart About Configure Usage & billing Optimize usage Troubleshoot Give feedback Docker Build Cloud Setup Usage Continuous integration Optimization Builder settings Release notes Docker Hub Quickstart Library Search Trusted content Catalogs Mirror Repositories Create Manage Repository information Access Images Tags Immutable tags Image Management Software artifacts Push images Move images Image security insights Webhooks Automated builds Set up Link accounts Automated repository tests Advanced options Manage autobuilds Troubleshoot Trusted content Docker Official Images Docker Verified Publisher Program Docker-Sponsored Open Source Program Insights and analytics Archive Delete Personal settings Usage and limits Pulls Optimize usage Service accounts Troubleshoot Release notes Docker Scout Install Quickstart Explore Dashboard Docker Scout image analysis Docker Scout metrics exporter Image details view Manage vulnerability exceptions How-tos Create an exception using the GUI Create an exception using the VEX Docker Scout environment variables Docker Scout SBOMs Use Scout with different artifact types Deep dive Advisory database sources and matching service Data collection and storage in Docker Scout Policy Evaluation Configure policies Docker Scout health scores Evaluate policy compliance in CI Remediation with Docker Scout View Docker Scout policy status Integrations Code quality SonarQube Container registries Amazon ECR Azure Container Registry Continuous Integration Azure DevOps Pipelines Circle CI GitHub Actions GitLab CI/CD Jenkins Integrating Docker Scout with environments Generic (CLI) Sysdig Source code management GitHub Team collaboration Slack Release notes CLI release notes Platform release notes Docker for GitHub Copilot EA Install Usage Example prompts Docker Extensions Marketplace extensions Non-marketplace extensions Configure a private marketplace Settings and feedback Extensions SDK The build and publish process Quickstart Part one: Build Create a simple extension Create an advanced frontend extension Add a backend to your extension Part two: Publish Add labels Validate Package and release your extension Share your extension Publish in the Marketplace Build multi-arch extensions Architecture Metadata Security Design and UI styling Guidelines Docker design principles MUI best practices Developer Guides Authentication Interacting with Kubernetes Invoke host binaries Use the Docker socket Developer SDK tools Test and debug Continuous Integration (CI) CLI reference Extension APIs Dashboard Docker Extension Backend Extension UI API Navigation Testcontainers Cloud Deprecated products and features Release lifecycle Platform Billing Add or update a payment method Manage your billing information 3D Secure authentication View billing history Change your billing cycle Submit a tax exemption certificate FAQs Docker accounts Accounts Create an account Manage an account Deactivate an account Security Personal access tokens Two-factor authentication Recover your Docker account FAQs General Container Network and VM Single sign-on General Domains Enforcement Identity providers User management Security announcements Subscription Subscriptions and features Set up your subscription Scale your subscription Manage seats Change your subscription Docker Desktop license agreement FAQs Release notes Enterprise Administration Organization administration Create your organization Onboard your organization Manage organization members Convert an account into an organization Create and manage a team Deactivate an organization Manage Docker products Activity logs Organization information Insights Company administration overview Create a company Manage company members Manage company organizations Manage company owners FAQ Organization Company Deploy Docker Desktop MSI installer PKG installer MS Store Deploy with Intune Deploy with Jamf Pro Microsoft Dev Box FAQs Security Single sign-on Configure Connect Manage Provision Just-in-Time SCIM Group mapping Enforce sign-in Configure Roles and permissions Manage domains Hardened Docker Desktop Enhanced Container Isolation Enable ECI Configure advanced settings Limitations FAQs Settings Management Use a JSON file Use the Admin Console Desktop settings reporting Settings reference Registry Access Management Image Access Management Air-gapped containers Organization access tokens Troubleshoot Troubleshoot provisioning Troubleshoot SSO Home / Manuals / Docker Engine / Swarm mode / Getting started with Swarm mode / Apply rolling updates to a service Apply rolling updates to a service Page options Copy page as Markdown for LLMs View page as plain text Ask questions with Docs AI Claude Open in Claude In a previous step of the tutorial, you scaled the number of instances of a service. In this part of the tutorial, you deploy a service based on the Redis 7.4.0 container tag. Then you upgrade the service to use the Redis 7.4.1 container image using rolling updates. If you haven't already, open a terminal and ssh into the machine where you run your manager node. For example, the tutorial uses a machine named manager1 . Deploy your Redis tag to the swarm and configure the swarm with a 10 second update delay. Note that the following example shows an older Redis tag: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service create \ --replicas 3 \ --name redis \ --update-delay 10s \ redis:7.4.0 0u6a4s31ybk7yw2wyvtikmu50 You configure the rolling update policy at service deployment time. The --update-delay flag configures the time delay between updates to a service task or sets of tasks. You can describe the time T as a combination of the number of seconds Ts , minutes Tm , or hours Th . So 10m30s indicates a 10 minute 30 second delay. By default the scheduler updates 1 task at a time. You can pass the --update-parallelism flag to configure the maximum number of service tasks that the scheduler updates simultaneously. By default, when an update to an individual task returns a state of RUNNING , the scheduler schedules another task to update until all tasks are updated. If at any time during an update a task returns FAILED , the scheduler pauses the update. You can control the behavior using the --update-failure-action flag for docker service create or docker service update . Inspect the redis service: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service inspect --pretty redis ID: 0u6a4s31ybk7yw2wyvtikmu50 Name: redis Service Mode: Replicated Replicas: 3 Placement: Strategy: Spread UpdateConfig: Parallelism: 1 Delay: 10s ContainerSpec: Image: redis:7.4.0 Resources: Endpoint Mode: vip Now you can update the container image for redis . The swarm manager applies the update to nodes according to the UpdateConfig policy: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service update --image redis:7.4.1 redis redis The scheduler applies rolling updates as follows by default: Stop the first task. Schedule update for the stopped task. Start the container for the updated task. If the update to a task returns RUNNING , wait for the specified delay period then start the next task. If, at any time during the update, a task returns FAILED , pause the update. Run docker service inspect --pretty redis to see the new image in the desired state: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service inspect --pretty redis ID: 0u6a4s31ybk7yw2wyvtikmu50 Name: redis Service Mode: Replicated Replicas: 3 Placement: Strategy: Spread UpdateConfig: Parallelism: 1 Delay: 10s ContainerSpec: Image: redis:7.4.1 Resources: Endpoint Mode: vip The output of service inspect shows if your update paused due to failure: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service inspect --pretty redis ID: 0u6a4s31ybk7yw2wyvtikmu50 Name: redis ...snip... Update status: State: paused Started: 11 seconds ago Message: update paused due to failure or early termination of task 9p7ith557h8ndf0ui9s0q951b ...snip... To restart a paused update run docker service update &lt;SERVICE-ID> . For example: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service update redis To avoid repeating certain update failures, you may need to reconfigure the service by passing flags to docker service update . Run docker service ps &lt;SERVICE-ID> to watch the rolling update: ]\s+/gm, '')); copying = true; setTimeout(() => copying = false, 2000);"> $ docker service ps redis NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR redis.1.dos1zffgeofhagnve8w864fco redis:7.4.1 worker1 Running Running 37 seconds \_ redis.1.88rdo6pa52ki8oqx6dogf04fh redis:7.4.0 worker2 Shutdown Shutdown 56 seconds ago redis.2.9l3i4j85517skba5o7tn5m8g0 redis:7.4.1 worker2 Running Running About a minute \_ redis.2.66k185wilg8ele7ntu8f6nj6i redis:7.4.0 worker1 Shutdown Shutdown 2 minutes ago redis.3.egiuiqpzrdbxks3wxgn8qib1g redis:7.4.1 worker1 Running Running 48 seconds \_ redis.3.ctzktfddb2tepkr45qcmqln04 redis:7.4.0 mmanager1 Shutdown Shutdown 2 minutes ago Before Swarm updates all of the tasks, you can see that some are running redis:7.4.0 while others are running redis:7.4.1 . The output above shows the state once the rolling updates are done. Next steps Next, you'll learn how to drain a node in the swarm. Drain a node Edit this page Request changes Product offerings Pricing About us Contribute Read llms.txt Cookies Settings Terms of Service Status Legal Copyright © 2013-2025 Docker Inc. All rights reserved.