From 7047631c6331631cd38d70f8ab41b371312b7890 Mon Sep 17 00:00:00 2001
From: Brandon Pfeifer <bpfeifer@influxdata.com>
Date: Thu, 18 Aug 2022 17:54:26 -0400
Subject: [PATCH] fix: resolve gnupg dirmngr issues

---
 influxdb/2.0/Dockerfile        | 23 ++++++++++++++---------
 influxdb/2.0/alpine/Dockerfile | 18 +++++++++++++-----
 influxdb/2.1/Dockerfile        | 28 ++++++++++++++--------------
 influxdb/2.1/alpine/Dockerfile | 25 ++++++++++++++-----------
 influxdb/2.2/Dockerfile        | 28 ++++++++++++++--------------
 influxdb/2.2/alpine/Dockerfile | 23 +++++++++++++----------
 influxdb/2.3/Dockerfile        | 28 ++++++++++++++--------------
 influxdb/2.3/alpine/Dockerfile | 23 +++++++++++++----------
 influxdb/2.4/Dockerfile        | 28 ++++++++++++++--------------
 influxdb/2.4/alpine/Dockerfile | 23 +++++++++++++----------
 10 files changed, 136 insertions(+), 111 deletions(-)

diff --git a/influxdb/2.0/Dockerfile b/influxdb/2.0/Dockerfile
index 9f0d75b..56ca456 100644
--- a/influxdb/2.0/Dockerfile
+++ b/influxdb/2.0/Dockerfile
@@ -5,6 +5,12 @@ RUN groupadd -r influxdb --gid=1000 && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
+
 # Install gosu for easy step-down from root.
 # https://github.com/tianon/gosu/releases
 ENV GOSU_VER 1.12
@@ -12,11 +18,7 @@ RUN set -eux; \
     dpkgArch="$(dpkg --print-architecture)" && \
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch" && \
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch.asc" && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && \
     chmod +x /usr/local/bin/gosu && \
     gosu --version && \
     gosu nobody true
@@ -31,17 +33,20 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    gpgconf --kill all && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}/influx* /usr/local/bin/ && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.0/alpine/Dockerfile b/influxdb/2.0/alpine/Dockerfile
index 49efc31..49172b0 100644
--- a/influxdb/2.0/alpine/Dockerfile
+++ b/influxdb/2.0/alpine/Dockerfile
@@ -9,6 +9,11 @@ RUN addgroup -S -g 1000 influxdb && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A
+
 ENV INFLUXDB_VERSION 2.0.9
 RUN set -eux && \
     ARCH="$(apk --print-arch)" && \
@@ -21,17 +26,20 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    gpgconf --kill all && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}/influx* /usr/local/bin/ && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.1/Dockerfile b/influxdb/2.1/Dockerfile
index c38feff..ce7d1f6 100644
--- a/influxdb/2.1/Dockerfile
+++ b/influxdb/2.1/Dockerfile
@@ -5,6 +5,12 @@ RUN groupadd -r influxdb --gid=1000 && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
+
 # Install gosu for easy step-down from root.
 # https://github.com/tianon/gosu/releases
 ENV GOSU_VER 1.12
@@ -12,11 +18,7 @@ RUN set -eux; \
     dpkgArch="$(dpkg --print-architecture)" && \
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch" && \
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch.asc" && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && \
     chmod +x /usr/local/bin/gosu && \
     gosu --version && \
     gosu nobody true
@@ -32,14 +34,9 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -53,16 +50,19 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.1/alpine/Dockerfile b/influxdb/2.1/alpine/Dockerfile
index 260a8fb..be0e2bb 100644
--- a/influxdb/2.1/alpine/Dockerfile
+++ b/influxdb/2.1/alpine/Dockerfile
@@ -9,7 +9,12 @@ RUN addgroup -S -g 1000 influxdb && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
-# Install the infuxd server
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A
+
+# Install the influxd server
 ENV INFLUXDB_VERSION 2.1.1
 RUN set -eux && \
     ARCH="$(apk --print-arch)" && \
@@ -22,14 +27,9 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -45,16 +45,19 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.2/Dockerfile b/influxdb/2.2/Dockerfile
index ece8710..977b21b 100644
--- a/influxdb/2.2/Dockerfile
+++ b/influxdb/2.2/Dockerfile
@@ -5,6 +5,12 @@ RUN groupadd -r influxdb --gid=1000 && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
+
 # Install gosu for easy step-down from root.
 # https://github.com/tianon/gosu/releases
 ENV GOSU_VER 1.12
@@ -12,11 +18,7 @@ RUN set -eux; \
     dpkgArch="$(dpkg --print-architecture)" && \
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch" && \
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch.asc" && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && \
     chmod +x /usr/local/bin/gosu && \
     gosu --version && \
     gosu nobody true
@@ -32,14 +34,9 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -53,16 +50,19 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.2/alpine/Dockerfile b/influxdb/2.2/alpine/Dockerfile
index 3baff75..3041c4e 100644
--- a/influxdb/2.2/alpine/Dockerfile
+++ b/influxdb/2.2/alpine/Dockerfile
@@ -9,6 +9,11 @@ RUN addgroup -S -g 1000 influxdb && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A
+
 # Install the infuxd server
 ENV INFLUXDB_VERSION 2.2.0
 RUN set -eux && \
@@ -22,14 +27,9 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -45,16 +45,19 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.3/Dockerfile b/influxdb/2.3/Dockerfile
index 0a3d979..f554963 100644
--- a/influxdb/2.3/Dockerfile
+++ b/influxdb/2.3/Dockerfile
@@ -5,6 +5,12 @@ RUN groupadd -r influxdb --gid=1000 && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
+
 # Install gosu for easy step-down from root.
 # https://github.com/tianon/gosu/releases
 ENV GOSU_VER 1.12
@@ -12,11 +18,7 @@ RUN set -eux; \
     dpkgArch="$(dpkg --print-architecture)" && \
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch" && \
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch.asc" && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && \
     chmod +x /usr/local/bin/gosu && \
     gosu --version && \
     gosu nobody true
@@ -32,14 +34,9 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2_linux_${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -53,16 +50,19 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.3/alpine/Dockerfile b/influxdb/2.3/alpine/Dockerfile
index 991698d..d7a1d16 100644
--- a/influxdb/2.3/alpine/Dockerfile
+++ b/influxdb/2.3/alpine/Dockerfile
@@ -9,6 +9,11 @@ RUN addgroup -S -g 1000 influxdb && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A
+
 # Install the infuxd server
 ENV INFLUXDB_VERSION 2.3.0
 RUN set -eux && \
@@ -22,14 +27,9 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2_linux_${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -45,16 +45,19 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.4/Dockerfile b/influxdb/2.4/Dockerfile
index c996cec..055bf33 100644
--- a/influxdb/2.4/Dockerfile
+++ b/influxdb/2.4/Dockerfile
@@ -5,6 +5,12 @@ RUN groupadd -r influxdb --gid=1000 && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
+
 # Install gosu for easy step-down from root.
 # https://github.com/tianon/gosu/releases
 ENV GOSU_VER 1.12
@@ -12,11 +18,7 @@ RUN set -eux; \
     dpkgArch="$(dpkg --print-architecture)" && \
     wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch" && \
     wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VER/gosu-$dpkgArch.asc" && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \
     gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc && \
     chmod +x /usr/local/bin/gosu && \
     gosu --version && \
     gosu nobody true
@@ -32,14 +34,9 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2_linux_${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -53,16 +50,19 @@ RUN set -eux && \
     esac && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
diff --git a/influxdb/2.4/alpine/Dockerfile b/influxdb/2.4/alpine/Dockerfile
index aade1c5..d364e07 100644
--- a/influxdb/2.4/alpine/Dockerfile
+++ b/influxdb/2.4/alpine/Dockerfile
@@ -9,6 +9,11 @@ RUN addgroup -S -g 1000 influxdb && \
     mkdir -p /home/influxdb && \
     chown -R influxdb:influxdb /home/influxdb
 
+# Configure GNUPG
+RUN mkdir -p /root/.gnupg && chmod 700 /root/.gnupg                                               && \
+    echo "disable-ipv6" >> /root/.gnupg/dirmngr.conf                                              && \
+    gpg --batch --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A
+
 # Install the infuxd server
 ENV INFLUXDB_VERSION 2.4.0
 RUN set -eux && \
@@ -22,14 +27,9 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2_linux_${ARCH}/influxd /usr/local/bin/influxd && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}* && \
     influxd version
 
 # Install the influx CLI
@@ -45,16 +45,19 @@ RUN set -eux && \
     fi && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc && \
     wget --no-verbose https://dl.influxdata.com/influxdb/releases/influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
-    export GNUPGHOME="$(mktemp -d)" && \
-    echo "disable-ipv6" >> $GNUPGHOME/dirmngr.conf && \
-    gpg --keyserver keys.openpgp.org --recv-keys 8C2D403D3C3BDB81A4C27C883C3E4B7317FFE40A && \
     gpg --batch --verify influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz.asc influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     tar xzf influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}.tar.gz && \
     cp influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}/influx /usr/local/bin/influx && \
-    gpgconf --kill all && \
-    rm -rf "$GNUPGHOME" influxdb2.key influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}* && \
     influx version
 
+# Remove GNUPG Configuration
+RUN gpgconf --kill all                                      && \
+    rm -rf                                                     \
+      "/root/.gnupg"                                           \
+      influxdb2.key                                            \
+      influxdb2-${INFLUXDB_VERSION}-linux-${ARCH}*             \
+      influxdb2-client-${INFLUX_CLI_VERSION}-linux-${ARCH}*
+
 # Create standard directories expected by the entry-point.
 RUN mkdir /docker-entrypoint-initdb.d && \
     mkdir -p /var/lib/influxdb2 && \
-- 
GitLab