Unable to apt-get update through dockerfile. Could not connect to archive.ubuntu.com:80 [duplicate]
I think I understand the problem. It was something to do with the proxy that docker was using, which was unrecognised (I think I may have changed it to an invalid address while troubleshooting other problems earlier)
There are 2 ways to go about this.
Before that, use echo $http_proxy
or echo $HTTP_PROXY
to find what proxy you are using, or if you have another proxy that works you can use that too.
Okay first method:
If you are running a dockerfile, before RUN apt-get update && apt-get upgrade
, set the environment with ENV
example:
FROM ubuntu:16.04
MAINTAINER [email protected]
ENV DEBIAN_FRONTEND noninteractive
ENV http_proxy 'http://mainproxy.ucm.conti.de:8980'
ENV https_proxy 'https://mainproxy.ucm.conti.de:8980'
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y
Note: according to Docker documentation, if you want to unset the proxy, you should use RUN instead, and unset it in the same command, otherwise the value will persist in a lower layer. Anyways,
Second method:
You can define the proxy in /etc/default/docker
sudo nano /etc/default/docker
//under the line "If you need Docker to use an HTTP proxy..."
#export http_proxy="http://yourproxy:port"
and this worked for me! Now I have a different problem but yes this is solved FINALLY!