I am facing a challenge while working with Docker in a corporate network environment. To overcome the network restrictions, I have configured the Docker daemon's DNS as mentioned in this Stack issue. Additionally, I have set the proxy environment variables in the Docker image as follows:
ENV http_proxy = http://login:pass@proxy-server.fr:1111
ENV https_proxy = http://login:pass@proxy-server.fr:1111
ENV ftp_proxy = http://login:pass@proxy-server.fr:1111
ENV no_proxy = 127.0.0.1, z.z.z.z , y.y.y.y, x.x.x.x,localhost
By doing this I succeded to bypass the apt-get, but the problem here is that when I try to do this by writing the proxy parameters inbside of /etc/environment using a command in this form:
RUN echo "\nexport http_proxy = http://login:pass@proxy-server.fr:1111\nexport https_proxy = ... etc" >> /etc/environment
In order to refresh the environment variables I follow this Stack issue by adding this line to change the default shell from /bin/sh to /bin/bash Note that this is needed otherwise you'll get the error /bin/sh source command not found
SHELL ["/bin/bash", "-c"]
RUN source /etc/environment
Then to check if the refreshing has happened I just type
env | grep proxy
There is no proxy configuration and there for I can not perform ** RUN apt-get update**
Note that if I run the container and perform this refreshing command
source /etc/environment
And then perform apt-get update every thing goes well !!!
I don't really get what is exactely the problem thank you for giving any explanation.
Thank you for your reading.
VERSIONS:
- Docker version 20.10.23
- Kubuntu 22.04 LTS