Docker Community Forums

Share and learn in the Docker community.

Configure https proxy in a dockerfile

I am trying to create a container with Docker that contains eclipse and some plugins. By now, I am trying to configure the proxy that I need for internet connexion and it works for the http but not for https.
Here is my dockerfile

FROM ubuntu:18.04

RUN echo 'Acquire::http::Proxy "http://localhost:8080";' > /etc/apt/apt.conf.d/90curtin-aptproxy && \
echo 'Acquire::https::Proxy "http://localhost:8080";' >> /etc/apt/apt.conf.d/90curtin-aptproxy && \
sed 's/main$/main universe/' -i /etc/apt/sources.list && \
apt-get update && \
apt-get install -y wget openjdk-8-jdk libxext-dev libxrender-dev libxtst-dev libgtk2.0-0 libcanberra-gtk-module zip unzip gnupg2 curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/*

RUN groupadd --gid 1000 user && useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash user

#ENV http_proxy=localhost:8080 https_proxy=localhost:8080

#ADD /tmp/eclipse-java-neon-3-linux-gtk-x86_64.tar.gz

#RUN tar -zxvf /tmp/eclipse-java-neon-3-linux-gtk-x86_64.tar.gz -C /opt/ && \
#rm /tmp/eclipse-java-neon-3-linux-gtk-x86_64.tar.gz

ADD ./eclipse-java-neon-3-linux-gtk-x86_64.tar.gz /opt/

RUN echo "-Dhttp.proxyHost=localhost" >> /opt/eclipse/eclipse.ini && \
echo "-Dhttp.proxyPort=8080" >> /opt/eclipse/eclipse.ini && \
echo "-Dhttps.proxyHost=localhost" >> /opt/eclipse/eclipse.ini && \
echo "-Dhttps.proxyPort=8080" >> /opt/eclipse/eclipse.ini && \
echo "-Dhttp.nonProxyHosts=localhost|" >> /opt/eclipse/eclipse.ini


RUN chmod u+x /


After the build and when I run my eclipse, and when I go into the settings the proxy for http is set, but for the https nothing changed.

Could you help me ?

Thank you !

From what I remember, I also had to use -Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclient as well.
You are aware that local host is reletive to the container, aren’t you?

Wouldn’t it more elegant to have an entrypoint script that sets the proxy settings for you, instead of backing it into the image? You could simply set -e $http_proxy and/or -e $https_proxy and -e $no_proxy to your container and let the entrypoint script take care of the configuration… This would allow to use the image with and without the proxy.

Thanks for your answer ! I know I could do this in a better way but I’m a beginner in using Docker and in bash scripting.
I just don’t understand why it works for the http and not for the https; is there any error in this code ?

Hint: your proxy points to localhost is the container && for https you did not specify -Dhttp.nonProxyHosts.

What exactly does not work? Are the values not prepopulated in eclipse’s proxy configuration settings?

Thank you for your help !
Yes, exactly, the values are not prepopulated in eclipse’s proxy configuration settings (for https)

I’m not sure to understand, you say that I didn’t specify the proxy point to https ?

Thist should have been -Dhttps.nonProxyHosts .

Anyway those are two set of problems:
– Eclipse: I do use the very same settings in an asible-role and it works.
– Unless you don’t use network=host, the container use a proxy inside the container. Is this what you want?