Last active
April 7, 2017 15:46
-
-
Save pascencio/6a8dd6d45f35fb64796ef022562d27ee to your computer and use it in GitHub Desktop.
Configuration of HTTP Proxy in Docker with Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/systemd/system/docker.service.d/http-proxy.conf | |
[Service] | |
EnvironmentFile=-/opt/proxy/bin/.docker_env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# /opt/proxy/bin/proxyenv | |
SHELL_DIR=/opt/proxy/bin | |
PROXY_ENV=${SHELL_DIR}/.proxy_env | |
DOCKER_ENV=${SHELL_DIR}/.docker_env | |
echo Proxy Host | |
read PROXY_HOST | |
echo Proxy Port | |
read PROXY_PORT | |
if [ -f $PROXY_ENV ] | |
then | |
echo Archivo de variables del proxy ya existe. | |
echo Las variable se sobrescribiran. | |
else | |
touch $PROXY_ENV | |
echo Archivo de variables del proxy creado. | |
fi | |
if [ -f $DOCKER_ENV ] | |
then | |
echo Archivo de variables del proxy para docker ya existe. | |
echo Las variable se sobrescribiran. | |
else | |
touch $DOCKER_ENV | |
echo Archivo de variables del proxy para docker creado. | |
fi | |
if [ "${PROXY_HOST}X" != "X" ] && [ "${PROXY_PORT}X" != "X" ] | |
then | |
URL="http://${PROXY_HOST}:${PROXY_PORT}" | |
else | |
URL="" | |
fi | |
echo "export HTTP_PROXY=${URL}" > $PROXY_ENV | |
echo "export HTTPS_PROXY=${URL}" >> $PROXY_ENV | |
echo "export http_proxy=${URL}" >> $PROXY_ENV | |
echo "export https_proxy=${URL}" >> $PROXY_ENV | |
echo "export NO_PROXY=localhost,127.0.0.1" >> $PROXY_ENV | |
echo "export no_proxy=localhost,127.0.0.1" >> $PROXY_ENV | |
echo "export PROXY_HOST=${PROXY_HOST}" >> $PROXY_ENV | |
echo "export PROXY_PORT=${PROXY_PORT}" >> $PROXY_ENV | |
echo "HTTP_PROXY=${URL}" > $DOCKER_ENV | |
echo "HTTPS_PROXY=${URL}" >> $DOCKER_ENV | |
echo "http_proxy=${URL}" >> $DOCKER_ENV | |
echo "https_proxy=${URL}" >> $DOCKER_ENV | |
echo | |
echo Ejecute el siguiente comando para cargar las variables del proxy: | |
echo "source ${PROXY_ENV}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment