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.
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 first, so you can return to the old version if the new one breaks.
- Run the commands as a user in the
dockergroup, or putsudoin front.
Which image tag should I use?
The tag inimage: decides what pull downloads.
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
compose.yaml.2
Download the new images
docker compose pull wordpress.3
Recreate the changed containers
compose.yaml. It recreates only the ones that changed and prints Recreated for them. Unchanged services keep running.4
Remove the old images
docker compose up -d --pull always does the pull and the recreate in one command.
How to check it worked
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: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.
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
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.
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 per project: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 hasbuild: 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.
Will updating lose my data?
Not if the data is in a volume or bind mount. Check withdocker inspect <container> --format '{{ json .Mounts }}'. Anything not listed there lives inside the container and is lost when it’s recreated.
Related guides
VPS and dedicated server guides
Every guide in this section.
Back up Docker volumes
Take a backup before every update.
Docker Compose tutorial
Manage apps from a compose.yaml file.
Clean up Docker disk space
Remove old images after updating.
Fix common Docker errors
When a container won’t start again.
Checked against the official Docker Compose CLI reference and 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.
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
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026