> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Update Docker Containers with Compose Pull

> Update a Docker container with Compose: run docker compose pull, then docker compose up -d to recreate it on the new image. Your volumes keep the data.

To update a Docker container that runs with Compose, go to its project folder and run `docker compose pull` to download the newer image, then `docker compose up -d` to recreate only the containers whose image changed. Data in volumes stays. For a container started with `docker run`, pull the image, remove the container and run it again with the same options.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Beginner | 5 minutes per app | Any Linux server with Docker | [Docker with Compose](https://help.freakhosting.com/portals/other/how-to-install-docker.md) |

## Before you start

* A container never changes its image. "Updating" means downloading a newer image and creating a new container from it. Anything stored inside the container, rather than in a volume or bind mount, is lost.
* Read the app's release notes before a major version jump (for example 1.x to 2.x). Databases and apps sometimes need a manual migration step.
* [Back up the app's volumes](https://help.freakhosting.com/portals/other/how-to-back-up-docker-volumes.md) first, so you can return to the old version if the new one breaks.
* Run the commands as a user in the `docker` group, or put `sudo` in front.

## Which image tag should I use?

The tag in `image:` decides what `pull` downloads.

| Tag style | Example | What `pull` gets |
| - | - | - |
| Exact version | `mariadb:11.4.13` | Nothing new, until you change the tag |
| Minor or major line | `mariadb:11.4`, `louislam/uptime-kuma:2` | Patches and fixes inside that line |
| `latest` | `nginx:latest` | Whatever the project publishes next, including major versions |

A version line such as `11.4` is a good default for servers: you get security fixes with every pull, and big upgrades only when you change the tag yourself.

## How to update containers with Docker Compose

**1. Go to the project folder**

```bash theme={null}
cd ~/wordpress
```

Use the folder that holds the app's `compose.yaml`.

**2. Download the new images**

```bash theme={null}
docker compose pull
```

To update one service only, name it: `docker compose pull wordpress`.

**3. Recreate the changed containers**

```bash theme={null}
docker compose up -d
```

Compose compares each container with the image and settings in `compose.yaml`. It recreates only the ones that changed and prints `Recreated` for them. Unchanged services keep running.

**4. Remove the old images**

```bash theme={null}
docker image prune
```

This deletes dangling images, the untagged layers left behind by the update. See [clean up Docker disk space](https://help.freakhosting.com/portals/other/how-to-clean-up-docker-disk-space.md).

`docker compose up -d --pull always` does the pull and the recreate in one command.

## How to check it worked

```bash theme={null}
docker compose ps
docker compose images
docker compose logs --tail 50
```

`ps` shows each container `Up` with a recent **CREATED** time, `images` shows the tag and image ID now in use, and the logs show the app starting without errors.

## How to update a container started with docker run

Compose isn't involved, so you repeat the original command. This example updates Portainer:

```bash theme={null}
docker pull portainer/portainer-ce:lts
docker stop portainer
docker rm portainer
docker run -d -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:lts
```

If you don't remember the options, run `docker inspect portainer` before you remove it and note the ports, volumes, environment variables and restart policy. Better still, move the app to a `compose.yaml` file so the options are written down; see the [Docker Compose tutorial](https://help.freakhosting.com/portals/other/how-to-use-docker-compose.md).

## How to roll back to the previous version

**1. Pin the old version**

Change the tag in `compose.yaml` to the exact version you ran before, for example `image: mariadb:11.4.12`.

**2. Recreate the container**

```bash theme={null}
docker compose up -d
```

**3. Restore data if needed**

If the new version already changed the database format, the old version may refuse to start. Restore the volume backup you took before updating; see [back up Docker volumes](https://help.freakhosting.com/portals/other/how-to-back-up-docker-volumes.md).

> [!WARNING]
>
> Never update by running `docker compose down -v`. The `-v` flag deletes your named volumes, which means your databases and uploads.

## How to update containers automatically

Choose automatic updates only for apps where a surprise restart or new version is acceptable. A simple, visible option is a weekly [cron job](https://help.freakhosting.com/portals/other/how-to-schedule-tasks-with-cron.md) per project:

```bash theme={null}
crontab -e
```

```bash theme={null}
30 4 * * 1 cd /home/alex/uptime-kuma && /usr/bin/docker compose pull -q && /usr/bin/docker compose up -d && /usr/bin/docker image prune -f
```

This runs at 04:30 every Monday. Watchtower, a popular auto-update container, was archived by its maintainers in December 2025 and no longer gets fixes, so don't install it on new servers.

## Frequently asked questions

### Does docker compose up -d restart containers that didn't change?

No. Compose leaves a container running when its image and configuration are the same. Add `--force-recreate` if you want every container recreated.

### Why didn't docker compose pull download anything?

Either the image is already the newest for that tag, or the service has `build:` instead of `image:`. For services you build yourself, run `docker compose build --pull` and then `docker compose up -d`.

### How do I update Docker itself?

Docker Engine updates with your system packages (`sudo apt upgrade` or `sudo dnf upgrade`). That is separate from updating the images your containers run. See [install Docker](https://help.freakhosting.com/portals/other/how-to-install-docker.md).

### Will updating lose my data?

Not if the data is in a volume or bind mount. Check with `docker inspect <container> --format '{{ json .Mounts }}'`. Anything not listed there lives inside the container and is lost when it's recreated.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Back up Docker volumes](https://help.freakhosting.com/portals/other/how-to-back-up-docker-volumes.md)
>
> Take a backup before every update.

> [card] [Docker Compose tutorial](https://help.freakhosting.com/portals/other/how-to-use-docker-compose.md)
>
> Manage apps from a compose.yaml file.

> [card] [Clean up Docker disk space](https://help.freakhosting.com/portals/other/how-to-clean-up-docker-disk-space.md)
>
> Remove old images after updating.

> [card] [Fix common Docker errors](https://help.freakhosting.com/portals/other/how-to-fix-common-docker-errors.md)
>
> When a container won't start again.

***

> [!NOTE]
>
> **Checked against the official [Docker Compose CLI reference](https://docs.docker.com/reference/cli/docker/compose/up/) and [docker compose pull](https://docs.docker.com/reference/cli/docker/compose/pull/) docs** on 4 November 2026; the pull, recreate and prune steps tested on Ubuntu 24.04 LTS with Docker Engine 29.9.2 and Docker Compose v5.6.1 using local images. Commands can differ on other releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.