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 image for TimescaleDB 2.17.x running on PostgreSQL 17. If you’re using another PostgreSQL version, look for the relevant tag in the TimescaleDB HA Docker Hub repository.docker pull timescale/timescaledb-ha:pg17
- Stop the old container, and remove it:docker stop timescaledbdocker rm timescaledb
- Launch a new container with the upgraded Docker image, pointing to the existing mount point. Make sure you copy the correct command, based on your mount point type.For volume mounts:
docker run -v ./data/db:/var/lib/postgresql/data \
-d --name timescaledb -p 5432:5432 timescale/timescaledb-ha
Connect to the upgraded instance using psql
with the -X
flag:
docker exec -it timescaledb psql -U postgres -X
At the psql prompt, use the ALTER
command to upgrade the extension:
ALTER EXTENSION timescaledb UPDATE;
Update the TimescaleDB Toolkit extension. Toolkit is packaged with TimescaleDB’s HA Docker image, and includes additional hyperfunctions to help you with queries and data analysis:
CREATE EXTENSION IF NOT EXISTS timescaledb_toolkit;
ALTER EXTENSION timescaledb_toolkit UPDATE;
If you have multiple databases, you need to update each database separately.
export DBNAMES=$(docker compose exec timescaledb psql \
-U usr -d postgres --no-align --tuples-only \
-qc 'SELECT datname from pg_database;')
for DBNAME in $DBNAMES; do
docker compose exec timescaledb psql -U usr -d ${DBNAME} \
-qc 'ALTER EXTENSION timescaledb UPDATE; CREATE EXTENSION IF NOT EXISTS timescaledb_toolkit; ALTER EXTENSION timescaledb_toolkit UPDATE;';
done