# Configure https proxy in a dockerfile

**URL:** <https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951>\
**Category:** General\
**Tags:** dockerhub\
**Created:** [August 19, 2019, 9:05am UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951 "2019-08-19T09:05:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lilemy11](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lilemy11](https://forums.docker.com/u/lilemy11)\
**Post date:** [August 19, 2019, 9:05am UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951/1 "2019-08-19T09:05:22Z")

</div>

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 https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/neon/3/eclipse-java-neon-3-linux-gtk-x86_64.tar.gz&r=1 /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|127.0.0.1" >> /opt/eclipse/eclipse.ini

COPY launch.sh /

RUN chmod u+x /launch.sh

ENTRYPOINT ["/launch.sh"]

```

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 !

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [August 19, 2019, 11:00am UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951/2 "2019-08-19T11:00:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lilemy11](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lilemy11](https://forums.docker.com/u/lilemy11)\
**Post date:** [August 19, 2019, 1:04pm UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951/3 "2019-08-19T13:04:27Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [August 19, 2019, 4:37pm UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951/4 "2019-08-19T16:37:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![lilemy11](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lilemy11](https://forums.docker.com/u/lilemy11)\
**Post date:** [August 20, 2019, 8:24am UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951/5 "2019-08-20T08:24:55Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [August 20, 2019, 11:00am UTC](https://forums.docker.com/t/configure-https-proxy-in-a-dockerfile/79951/6 "2019-08-20T11:00:01Z")

</div>

> [@meyay](#):
>
> Hint: your proxy points to localhost is the container && for https you did not specify `-Dhttp.nonProxyHosts` .

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?
