'How to upgrade postgres-client package in Docker container built from Airflow image based on Debian10

I'm trying to dump a database that is in Postgres13 from within Docker built from Airflow:2.2.3 image which runs Debian10 as far as I can tell. This image comes with postgresql-client-11 so I'm getting an error when I try to dump due to version mismatch between the client in docker (v11) and the database outside docker (v13).

I've tried to upgrade the postgresql-client to version 13 when building the docker image but when I log in the container it still shows version 11, and the attempt to dump the database results in the same version mismatch. Any idea how to upgrade the postgres-client version when building the docker image?

My current Dockerfile:

FROM apache/airflow:2.2.3-python3.9

USER root
RUN apt-get install curl ca-certificates \
    && curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        build-essential postgresql-client-13 \
    && apt-get autoremove -yqq --purge \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

(...)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source