Dockerfile mit einheitlicher Proxy-Konfiguration
Dieses Beispiel zeigt, wie du über einen einzigen Build‑Argument (ARG proxy) die Proxy‑Einstellungen in deinem Image definierst und sowohl für APT als auch für alle Laufzeit‑Prozesse (Java, Curl, Gradle, …) verwendest.
Dockerfile
FROM openjdk:17-jdk-bullseye
# 1) Build‑Argument: Proxy im Format ip:port
ARG proxy
# 2) ENV‑Variablen: PROXY-URL und Ausnahmen
ENV PROXY=http://${proxy} \
NO_PROXY=localhost,127.0.0.1
# 3) APT‑Proxy konfigurieren
RUN cat <<EOF > /etc/apt/apt.conf.d/02proxy
Acquire::http::Proxy "${PROXY}";
Acquire::https::Proxy "${PROXY}";
EOF
# 4) Systemweite Proxy‑Variablen in /etc/environment anhängen
RUN cat <<EOF >> /etc/environment
HTTP_PROXY="${PROXY}"
HTTPS_PROXY="${PROXY}"
http_proxy="${PROXY}"
https_proxy="${PROXY}"
NO_PROXY="${NO_PROXY}"
no_proxy="${NO_PROXY}"
EOF
# … weitere Build‑Steps hier (z.B. Installation, Copy, CMD)