Adding support for using Docker behind a proxy

This commit is contained in:
Aric Renzo 2017-06-16 15:06:33 -04:00
parent fce98459a6
commit ec5111949d
3 changed files with 63 additions and 2 deletions

View File

@ -8,6 +8,13 @@ fi
set -ex
#Set working directory relative to script
SCRIPT_DIR=$(dirname $0)
pushd $SCRIPT_DIR
#Load Variables File
. variables.sh
mkdir -p /etc/docker
cat <<EOS > /etc/docker/daemon.json
{
@ -16,10 +23,16 @@ cat <<EOS > /etc/docker/daemon.json
}
EOS
#Configuration for Docker Behind a Proxy
if [ $USE_PROXY == true ]; then
mkdir -p /etc/systemd/system/docker.service.d
CreateProxyConfiguraton
fi
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq --no-install-recommends \
docker.io \
docker.io=$DOCKER_VERSION \
if [ -f "${PROMENADE_LOAD_IMAGE}" ]; then

15
join.sh
View File

@ -8,6 +8,13 @@ fi
set -ex
#Set working directory relative to script
SCRIPT_DIR=$(dirname $0)
pushd $SCRIPT_DIR
#Load Variables File
. variables.sh
mkdir -p /etc/docker
cat <<EOS > /etc/docker/daemon.json
{
@ -16,10 +23,16 @@ cat <<EOS > /etc/docker/daemon.json
}
EOS
#Configuration for Docker Behind a Proxy
if [ $USE_PROXY == true ]; then
mkdir -p /etc/systemd/system/docker.service.d
CreateProxyConfiguraton
fi
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq --no-install-recommends \
docker.io \
docker.io=$DOCKER_VERSION \
if [ -f "${PROMENADE_LOAD_IMAGE}" ]; then

35
variables.sh Normal file
View File

@ -0,0 +1,35 @@
#!/bin/bash
#Promenade Variables
DOCKER_VERSION=1.12.6-0ubuntu1~16.04.1
PROMENADE_LOAD_IMAGE=$SCRIPT_DIR/promenade.tar
#HTTP Proxy Variables
USE_PROXY=false
DOCKER_HTTP_PROXY="http://proxy.server.com:8080"
DOCKER_HTTPS_PROXY="https://proxy.server.com:8080"
DOCKER_NO_PROXY="localhost,127.0.0.1"
function CreateProxyConfiguraton {
#Set HTTP Proxy variable
cat <<EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=${DOCKER_HTTPS_PROXY}"
EOF
#Set HTTPS Proxy Variable
cat <<EOF > /etc/systemd/system/docker.service.d/https-proxy.conf
[Service]
Environment="HTTPS_PROXY=${DOCKER_HTTPS_PROXY}"
EOF
#Set No Proxy Variable
cat <<EOF > /etc/systemd/system/docker.service.d/no-proxy.conf
[Service]
Environment="NO_PROXY=${DOCKER_NO_PROXY}"
EOF
#Reload systemd and docker if present
systemctl daemon-reload
systemctl restart docker || true
}