Skip to content

Instantly share code, notes, and snippets.

@johnbintz
Created November 13, 2015 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save johnbintz/a0284678e7efc780cc1e to your computer and use it in GitHub Desktop.
Save johnbintz/a0284678e7efc780cc1e to your computer and use it in GitHub Desktop.
squid-deb-proxy for docker, because bandwidth is a thing
#!/bin/bash
docker run -it --name squid-deb-proxy-cache -v /var/cache/squid-deb-proxy busybox true
docker run -d --restart=always --name squid-deb-proxy --volumes-from squid-deb-proxy-cache -p 0.0.0.0:48000:8000 pmoust/squid-deb-proxy
# put this at the top of the dockerfile
# If host is running squid-deb-proxy on port 48000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo -n "GET / HTTP/1.0\n\n" | nc `cat /tmp/host_ip.txt` 48000 \
&& (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):48000\";" > /etc/apt/apt.conf.d/30proxy) \
&& (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
|| echo "No squid-deb-proxy detected on docker host"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment