Skip to content

Instantly share code, notes, and snippets.

@eric-glb
Created February 14, 2023 20:18
Show Gist options
  • Save eric-glb/e9426752d0be6843114dc92b00d4acf8 to your computer and use it in GitHub Desktop.
Save eric-glb/e9426752d0be6843114dc92b00d4acf8 to your computer and use it in GitHub Desktop.

Use a squid proxy cache container for container build

Assuming we run a squid container configured.

Ensure the RH-based container will only use one external repo

FROM centos:7
RUN  sed -i '/^mirrorlist/d; s/^#baseurl=/baseurl=/' /etc/yum.repos.d/*.repo
...

The proxy should be accessible using the bridge IP

PROXY=$(docker network inspect bridge | jq -r '.[].IPAM.Config[].Gateway')

The docker build command

docker build -t test . --build-arg http_proxy=http://${PROXY}:3128/ \
                       --build-arg https_proxy=http://${PROXY}:3128/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment