Upgrades within a Docker container

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.

note

In this section, the examples 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

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.

Determining the mount point type

  1. Work out what type of mount your Docker container uses by running this command, which returns either volume or bind:

    docker inspect timescaledb --format='{{range .Mounts }}{{.Type}}{{end}}'
  2. Get the current name or mount path with this command, and record it to use when you perform the upgrade. Make sure you copy the correct command, based on your mount point type.

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.

Upgrading TimescaleDB within Docker

  1. Pull the latest TimescaleDB image. This command pulls the image for PostgreSQL 14. If you're using another PostgreSQL version, look for the relevant tag in the TimescaleDB HA Docker Hub repository.

    docker pull timescale/timescaledb-ha:pg14-latest
  2. Stop the old container, and remove it:

    docker stop timescaledb
    docker rm timescaledb
  3. 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:

  4. Connect to the upgraded instance using psql with the -X flag:

    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;
  6. 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;

Found an issue on this page?

Report an issue!

Keywords

Related Content