Watchtower Docker Compose Example & Setup Guide

If you’re already using Docker Compose, you’ve likely built a clean, repeatable way to run your containers. But keeping those containers updated? That’s where things start to slip.

Manually pulling images and restarting services breaks the whole “automation” promise.

That’s why many developers search for watchtower docker compose—to combine the simplicity of Compose with automatic updates.

This guide shows you exactly how to do that, without losing control over your setup.
What Is Watchtower Docker Compose?

Watchtower Docker Compose refers to running the Watchtower container alongside your existing services using a docker-compose.yml file.

Instead of running Watchtower manually via CLI, you define it as a service—just like any other container in your stack.

This approach gives you:

  • A cleaner setup
  • Better reproducibility
  • Easier configuration management

In short, it brings Watchtower into your existing Compose workflow.

Why Use Watchtower with Docker Compose?

If you’re already using Compose, adding Watchtower this way just makes sense.

Centralized Configuration

Everything lives in one file. No separate commands or scripts.

Easier Deployment

Spin up Watchtower with docker compose up -d like any other service.

Consistency Across Environments

Reuse the same setup across local, staging, and production.

Cleaner Maintenance

No need to remember how Watchtower was started—it’s documented in your Compose file.

Basic Watchtower Docker Compose Example

Here’s a simple, working example:

version: "3"

services:
  watchtower:
    image: containrrr/watchtower
    container_name: watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped

What this configuration does:

  • Uses the official Watchtower image
  • Mounts the Docker socket so it can monitor containers
  • Keeps Watchtower running automatically

Once this is running, Watchtower will monitor all containers on the host.

Adding Watchtower to an Existing Compose Stack

Let’s say you already have services defined:

version: "3"

services:
  app:
    image: your-app:latest
    ports:
      - "3000:3000"

  database:
    image: postgres:latest

  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Now Watchtower runs alongside your application and database, updating them when needed.

How Watchtower Works with Compose Services

Watchtower doesn’t care how containers were created.

Whether started via CLI or Docker Compose, it:

  • Detects running containers
  • Checks for updated images
  • Recreates containers when updates are available

That means your Compose-managed containers stay up to date without extra steps.

Updating every container automatically can be risky.

Instead, use labels to control which containers Watchtower updates.

Example:

services:
  app:
    image: your-app:latest
    labels:
      - "com.centurylinklabs.watchtower.enable=true"

Then run Watchtower with label filtering enabled.

This gives you:

  • Selective updates
  • Better control over production systems
  • Reduced risk of unexpected changes

Scheduling Updates in Docker Compose

By default, Watchtower checks for updates continuously.

But you can schedule updates using environment variables.

Example:

services:
  watchtower:
    image: containrrr/watchtower
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - WATCHTOWER_SCHEDULE=0 0 4 * * *

What this does:

  • Runs updates daily at 4 AM
  • Avoids peak usage times
  • Adds predictability

Scheduling is one of the most important best practices.

Running Watchtower Once (Manual Mode)

If you don’t want continuous updates, you can run Watchtower once.

Example:

command: --run-once

This is useful when:

  • You want controlled updates
  • You trigger updates manually
  • You integrate with deployment workflows

Notifications in Docker Compose

Knowing when updates happen is critical.

You can configure notifications directly in your Compose file.

Example (basic):

environment:
  - WATCHTOWER_NOTIFICATIONS=shoutrrr

Watchtower supports multiple notification systems, including:

  • Email
  • Slack
  • Discord
  • Webhooks

This helps you stay informed without constantly checking logs.

Best Practices for Watchtower Docker Compose

1. Avoid Updating Everything Automatically

Use labels to limit updates to safe containers.

2. Schedule Updates

Don’t let updates happen randomly during peak traffic.

3. Use Stable Image Tags

Avoid latest in production unless you’re comfortable with risk.

4. Keep Backups

Always assume updates can fail.

5. Test in Staging First

Run Watchtower in non-production environments before deploying widely.

Common Mistakes to Avoid

Running Without Restrictions

Updating all containers blindly can break dependencies.

Ignoring Logs

Watchtower logs provide insight into updates and failures.

Skipping Notifications

Without alerts, you won’t know when something changes.

Using It in Critical Systems Without Safeguards

Automation should support stability—not replace it.

When to Use Watchtower Docker Compose

Use it when:

  • You want simple automation
  • You manage small to mid-sized setups
  • You prefer minimal DevOps overhead

Avoid it when:

  • You need strict deployment pipelines
  • You rely on version pinning
  • You operate high-risk production systems

Watchtower vs CI/CD (Quick Perspective)

Watchtower is not a full deployment system.

It’s a convenience tool.

FeatureWatchtowerCI/CD
AutomationYesYes
ControlLimitedHigh
RollbackNoYes
ComplexityLowHigh

If your needs grow, you may eventually outgrow Watchtower.

If you want to go beyond Compose and understand full automation strategies, this guide covers it in detail: https://watchtowerdocker.com/2026/02/11/automating-docker-deployment-and-management-a-complete-guide-to-docker-watchtower-and-more/

8. Conclusion

Watchtower Docker Compose is one of the simplest ways to automate container updates without overengineering your setup.

It fits naturally into existing Compose workflows and reduces maintenance overhead.

But like any automation tool, it needs boundaries.

Use it where it adds value. Control it where stability matters.

That balance is what makes Watchtower effective.

9. FAQ Section

Can I use Watchtower with Docker Compose?

Yes. You can define Watchtower as a service inside your docker-compose.yml file and run it alongside your containers.

Does Watchtower update all containers automatically?

By default, yes. But you can restrict updates using labels.

How often does Watchtower check for updates?

It runs continuously unless you define a schedule using environment variables.

Is Watchtower safe for production?

It can be, but only with proper controls like scheduling and container filtering.

Can I stop Watchtower from updating certain containers?

Yes. Use labels to exclude or include specific containers.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top