From 6039be175e804f2d0cb5720c1d66d474599058be Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 19 Jan 2018 02:15:10 +0000 Subject: [PATCH 1/2] Enable proxy settings for docker run Signed-off-by: Qi Luo --- dockers/docker-sonic-mgmt/Dockerfile.j2 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dockers/docker-sonic-mgmt/Dockerfile.j2 b/dockers/docker-sonic-mgmt/Dockerfile.j2 index be2f1b6518b5..a1a4e0add359 100644 --- a/dockers/docker-sonic-mgmt/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt/Dockerfile.j2 @@ -96,3 +96,14 @@ RUN tar -xvzf azure-cli_bundle.tar.gz RUN azure-cli_bundle_*/installer RUN git clone https://github.com/Azure/sonic-mgmt + +# Forward all proxy settings from 'docker run' command line to container scope startup script. +# So even ssh client has them. All env variables are optional +# Sample command: +# docker run -e "http_proxy=ip1" -e "ftp_proxy=ip2" -it +# +ENTRYPOINT bash -c "touch /etc/profile.d/proxy.sh \ + && echo 'export http_proxy=${http_proxy}' >> /etc/profile.d/proxy.sh \ + && echo 'export https_proxy=${http_proxy}' >> /etc/profile.d/proxy.sh \ + && echo 'export ftp_proxy=${http_proxy}' >> /etc/profile.d/proxy.sh \ + && bash" From d44b728c1a666f819c086d65a19f4614e0dfacaa Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 19 Jan 2018 07:35:43 +0000 Subject: [PATCH 2/2] Fix user privilege and env typos Signed-off-by: Qi Luo --- dockers/docker-sonic-mgmt/Dockerfile.j2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dockers/docker-sonic-mgmt/Dockerfile.j2 b/dockers/docker-sonic-mgmt/Dockerfile.j2 index a1a4e0add359..f9578cba45a7 100644 --- a/dockers/docker-sonic-mgmt/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt/Dockerfile.j2 @@ -102,8 +102,8 @@ RUN git clone https://github.com/Azure/sonic-mgmt # Sample command: # docker run -e "http_proxy=ip1" -e "ftp_proxy=ip2" -it # -ENTRYPOINT bash -c "touch /etc/profile.d/proxy.sh \ - && echo 'export http_proxy=${http_proxy}' >> /etc/profile.d/proxy.sh \ - && echo 'export https_proxy=${http_proxy}' >> /etc/profile.d/proxy.sh \ - && echo 'export ftp_proxy=${http_proxy}' >> /etc/profile.d/proxy.sh \ +ENTRYPOINT bash -c "sudo touch /etc/profile.d/proxy.sh \ + && echo 'export http_proxy=${http_proxy}' | sudo tee -a /etc/profile.d/proxy.sh \ + && echo 'export https_proxy=${https_proxy}' | sudo tee -a /etc/profile.d/proxy.sh \ + && echo 'export ftp_proxy=${ftp_proxy}' | sudo tee -a /etc/profile.d/proxy.sh \ && bash"