Skip to content

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.

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.

  1. Find the mount type used by your Docker container
    Terminal window
    docker inspect timescaledb --format='{{range .Mounts }}{{.Type}}{{end}}'

    This returns either volume or bind.

  2. 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:

    069ba64815f0c26783b81a5f0ca813227fde8491f429cf77ed9a5ae3536c0b2c

    You use this value when you perform the upgrade.

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.

  1. Pull the latest TimescaleDB image

    This command pulls the latest version of TimescaleDB running on PostgreSQL 18:

    docker pull timescale/timescaledb-ha:pg18

    If you’re using another version of PostgreSQL, look for the relevant tag in the TimescaleDB HA repository on Docker Hub.

  2. Stop the old container, and remove it
    Terminal window
    docker stop timescaledb
    docker rm timescaledb
  3. 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:pg18
  4. Connect to the upgraded instance using psql with the -X flag
    Terminal window
    docker exec -it timescaledb psql -U postgres -X
  5. At the psql prompt, use the ALTER command to upgrade the extension
    ALTER 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.

    Note

    If you have multiple databases, update each database separately.