Skip to content

Instantly share code, notes, and snippets.

@aogilvie
Last active November 14, 2016 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aogilvie/0d76d5a5f16c2f652927819f4450e37f to your computer and use it in GitHub Desktop.
Save aogilvie/0d76d5a5f16c2f652927819f4450e37f to your computer and use it in GitHub Desktop.
Proxy Things For Docker

Notes on using proxy env vars with Docker or Dockerfile

Running the daemon behind a proxy:

sudo env https_proxy=http://proxy:8080 docker daemon

Building

sudo docker build --build-arg HTTP_PROXY=$http_proxy -t some/imagename .

//Dockerfile

RUN wget -e http_proxy=$http_proxy ...

Using a proxy in package managers

Building image FROM Centos

Sample environment file:

http_proxy="http://proxy:8080/"
https_proxy="http://proxy:8080/"
ftp_proxy="ftp://proxy:8080/"
no_proxy=".mylan.local,.domain1.com,host1,host2"

Sample Dockerfile:

COPY  deps/environment /etc/environment
// If private rpm
// COPY  deps/yum.repos.d /etc/yum.repos.d
// COPY  deps/rpm-gpg /etc/pki/rpm-gpg

Building image FROM Ubuntu/debian

Sample proxysettings file:

Acquire::http::proxy "http://proxy:8080";
Acquire::https::proxy "http://proxy:8080";
Acquire::ftp::proxy "http://proxy:8080";

Sample proxy.sh file:

export http_proxy=http://proxy:8080
export https_proxy=http://proxy:8080

Sample Dockerfile:

COPY proxysettings /etc/apt/apt.conf.d/proxysettings
COPY proxy.sh /etc/profile.d/proxy.sh
RUN  ./etc/profile.d/proxy.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment