Docker Community Forums

Share and learn in the Docker community.

Trying to update proxy config file on Ubuntu container without vi so that I can download vi using apt-get through my proxy?

#1

I have installed Docker on Windows 10, and ran a new ubuntu container.

Now on the container, I run ‘apt-get update’ and it says: Could not connect to archive.ubuntu.com:80 (91.189.88.161).

Understandable, I am behind a proxy which I need to authenticate against.

According to this article: https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-the-proxy-for-apt-for-ubuntu-18-04/

I need to update the proxy.conf file with my proxy settings.

Great, but vi isn’t installed so I can edit the config file, and I cant install vi without using apt-get which needs me to edit the proxy.conf using vi…???

Now what?

Any ideas?

(Gary Forghetti) #2

Here’s an example. Change the http://user:password@proxy.server:port/ below to match what your proxy needs.

🐳  gforghetti@172.28.128.3:[~] $ sudo touch /etc/apt/apt.conf.d/proxy.conf
🐳  gforghetti@172.28.128.3:[~] $ echo 'Acquire::https::Proxy "http://user:password@proxy.server:port/";'| sudo tee -a /etc/apt/apt.conf.d/proxy.conf
Acquire::https::Proxy "http://user:password@proxy.server:port/";
🐳  gforghetti@172.28.128.3:[~] $ cat /etc/apt/apt.conf.d/proxy.conf
Acquire::https::Proxy "http://user:password@proxy.server:port/";
🐳  gforghetti@172.28.128.3:[~] $
2 Likes
#3

Thank you, worked perfectly!

(Metin Y.) #4

What about the good old http_proxy enviornment variable? When set, apt-get uses it :slight_smile:

export http_proxy=proxy.mycompany.com:80

I only use Acquire::https::Proxy when a repository cache like apt-cacher-ng is available in the environment. This allows to use a different proxy for general web downloads and a specific configuration for the repository cache.

1 Like
#5

Hi

I originally did try and use the environment variable:

export http_proxy=http://username:password@proxy.host.co.za:8080

However, it seemed to take the proxy host and port, however, ignored the authentication details (username & password). I kept getting 407 Authentication Required responses.

According to the link in my original post, it says: Aptitude will not use the HTTP Proxy environment variables. Instead, it has its own configuration file where you can set your proxy.

Perhaps this has something to do with it not using the authentication details.

This is why I was looking at how to update the proxy.conf file.

#6

Although I am now getting further than before, it appears that some packages during download still say 407 Proxy Authentication Required.

root@8d9e473f6645:/# apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
file libexpat1 libgpm2 libmagic-mgc libmagic1 libmpdec2 libpython3.6 libpython3.6-minimal libpython3.6-stdlib libreadline7 libsqlite3-0 libssl1.1 mime-support readline-common vim-common vim-runtime xxd xz-utils
Suggested packages:
gpm readline-doc ctags vim-doc vim-scripts
The following NEW packages will be installed:
file libexpat1 libgpm2 libmagic-mgc libmagic1 libmpdec2 libpython3.6 libpython3.6-minimal libpython3.6-stdlib libreadline7 libsqlite3-0 libssl1.1 mime-support readline-common vim vim-common vim-runtime xxd xz-utils
0 upgraded, 19 newly installed, 0 to remove and 3 not upgraded.
Need to get 12.7 MB of archives.
After this operation, 61.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic-mgc amd64 1:5.32-2ubuntu0.1 [184 kB]
Ign:2 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.1
Get:3 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 file amd64 1:5.32-2ubuntu0.1 [22.1 kB]
Get:4 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 libexpat1 amd64 2.2.5-3 [80.2 kB]
Get:2 ttp://security.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.1 [68.4 kB]
Get:5 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 libmpdec2 amd64 2.4.2-1ubuntu1 [84.1 kB]
Get:6 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl1.1 amd64 1.1.0g-2ubuntu4.3 [1130 kB]
Get:7 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6-minimal amd64 3.6.7-1~18.04 [531 kB]
Err:8 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 mime-support all 3.60ubuntu1
407 Proxy Authentication Required [IP: 10.11.11.65 8080]
Get:9 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 readline-common all 7.0-3 [52.9 kB]
Get:10 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 libreadline7 amd64 7.0-3 [124 kB]
Get:11 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 libsqlite3-0 amd64 3.22.0-1 [496 kB]
Get:12 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6-stdlib amd64 3.6.7-1~18.04 [1711 kB]
Get:13 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 xxd amd64 2:8.0.1453-1ubuntu1 [49.2 kB]
Get:14 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 vim-common all 2:8.0.1453-1ubuntu1 [70.4 kB]
Get:15 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 xz-utils amd64 5.2.2-1.3 [83.8 kB]
Get:16 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 libgpm2 amd64 1.20.7-5 [15.1 kB]
Get:17 ttp://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6 amd64 3.6.7-1~18.04 [1415 kB]
Get:18 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 vim-runtime all 2:8.0.1453-1ubuntu1 [5437 kB]
Get:19 ttp://archive.ubuntu.com/ubuntu bionic/main amd64 vim amd64 2:8.0.1453-1ubuntu1 [1152 kB]
Fetched 12.7 MB in 2s (5312 kB/s)
E: Failed to fetch ttp://archive.ubuntu.com/ubuntu/pool/main/m/mime-support/mime-support_3.60ubuntu1_all.deb 407 Proxy Authentication Required [IP: 10.11.11.65 8080]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Why would some seem fine and other complain about proxy authentication?

(note in the above pasted trace I have removed the first ‘h’ from ‘http’ so it wouldnt be seen as a link and let me post this)

#7

Strange, if I run apt-get install vim from directory “/etc/apt” then there are no proxy authentication issues?

(Metin Y.) #8

Actualy, I never thried it with a proxy that requires auth.

We use the http_proxy settings as --build-arg while building our containers. Without it apt-get can’t install a single package during the build.