Upgrade TimescaleDB running in Docker
Upgrade self-hosted TimescaleDB running in a Docker container to a new minor version
If you originally installed TimescaleDB using Docker, you can upgrade from within the Docker container. This allows you to upgrade to the latest TimescaleDB version while retaining your data.
The timescale/timescaledb-ha* images have the files necessary to run previous versions. Patch releases
only contain bugfixes so should always be safe. Non-patch releases may rarely require some extra steps.
These steps are mentioned in the release notes for the version of TimescaleDB
that you are upgrading to.
After you upgrade the docker image, you run ALTER EXTENSION for all databases using TimescaleDB.
The examples in this page use a Docker instance called timescaledb. If you
have given your Docker instance a different name, replace it when you issue the
commands.
Determine the mount point type
Section titled “Determine the mount point type”When you start your upgraded Docker container, you need to be able to point the new Docker image to the location that contains the data from your previous version. To do this, you need to work out where the current mount point is. The current mount point varies depending on whether your container is using volume mounts, or bind mounts.
- Find the mount type used by your Docker container
Terminal window docker inspect timescaledb --format='{{range .Mounts }}{{.Type}}{{end}}'This returns either
volumeorbind. - Note the volume or bind used by your container
Terminal window docker inspect timescaledb --format='{{range .Mounts }}{{.Name}}{{end}}'Docker returns the
<volume ID>. You see something like this:069ba64815f0c26783b81a5f0ca813227fde8491f429cf77ed9a5ae3536c0b2cTerminal window docker inspect timescaledb --format='{{range .Mounts }}{{.Source}}{{end}}'Docker returns the
<bind path>. You see something like this:/path/to/dataYou use this value when you perform the upgrade.
Upgrade TimescaleDB within Docker
Section titled “Upgrade TimescaleDB within Docker”To upgrade TimescaleDB within Docker, you need to download the upgraded image, stop the old container, and launch the new container pointing to your existing data.
- Pull the latest TimescaleDB image
This command pulls the latest version of TimescaleDB running on PostgreSQL 18:
docker pull timescale/timescaledb-ha:pg18If you’re using another version of PostgreSQL, look for the relevant tag in the TimescaleDB HA repository on Docker Hub.
- Stop the old container, and remove it
Terminal window docker stop timescaledbdocker rm timescaledb - Launch a new container with the upgraded Docker image
Launch based on your mount point type:
Terminal window docker run -v <volume ID>:/pgdata -e PGDATA=/pgdata-d --name timescaledb -p 5432:5432 timescale/timescaledb-ha:pg18Terminal window docker run -v <bind path>:/pgdata -e PGDATA=/pgdata -d --name timescaledb \-p 5432:5432 timescale/timescaledb-ha:pg18 - Connect to the upgraded instance using psql with the -X flag
Terminal window docker exec -it timescaledb psql -U postgres -X - At the
psqlprompt, use theALTERcommand to upgrade the extensionALTER EXTENSION timescaledb UPDATE;CREATE EXTENSION IF NOT EXISTS timescaledb_toolkit;ALTER EXTENSION timescaledb_toolkit UPDATE;The TimescaleDB Toolkit extension is packaged with TimescaleDB HA, it includes additional hyperfunctions to help you with queries and data analysis.
NoteIf you have multiple databases, update each database separately.
- Pull the latest TimescaleDB image
This command pulls the latest version of TimescaleDB running on PostgreSQL 18.
docker pull timescale/timescaledb:latest-pg18If you’re using another version of PostgreSQL, look for the relevant tag in the TimescaleDB light repository on Docker Hub.
- Stop the old container, and remove it
Terminal window docker stop timescaledbdocker rm timescaledb - Launch a new container with the upgraded Docker image
Launch based on your mount point type:
Terminal window docker run -v <volume ID>:/pgdata -e PGDATA=/pgdata \-d --name timescaledb -p 5432:5432 timescale/timescaledb:latest-pg18Terminal window docker run -v <bind path>:/pgdata -e PGDATA=/pgdata -d --name timescaledb \-p 5432:5432 timescale/timescaledb:latest-pg18 - Connect to the upgraded instance using psql with the -X flag
Terminal window docker exec -it timescaledb psql -U postgres -X - At the
psqlprompt, use theALTERcommand to upgrade the extensionALTER EXTENSION timescaledb UPDATE;NoteIf you have multiple databases, you need to update each database separately.