Docker Community Forums

Share and learn in the Docker community.

Docker stuck with fetching packages from archive.ubuntu.com

Hi, I am new to Docker. I have the following Dockerfile

#Intermediate image (to hide your ssh key)
FROM ubuntu as intermediate

# Use bash
SHELL ["/bin/bash", "-c"]

# Home of root
WORKDIR /root

# install git
RUN apt-get update
RUN apt-get install -y git

Which gets stuck at the RUN apt-get update instruction

Step 4/23 : RUN apt-get update
---> Using cache
---> 63294fdb3ce6
Step 5/23 : RUN apt-get install -y git
---> Running in 55f4ebee1965
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
ca-certificates git-man krb5-locales less libasn1-8-heimdal libbsd0
libcurl3-gnutls libedit2 liberror-perl libexpat1 libgdbm-compat4 libgdbm5
libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3 libkeyutils1
libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common
libnghttp2-14 libperl5.26 libpsl5 libroken18-heimdal librtmp1 libsasl2-2
libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.0.0 libssl1.1
libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
libxmuu1 multiarch-support netbase openssh-client openssl patch perl
perl-modules-5.26 publicsuffix xauth
Suggested packages:
gettext-base git-daemon-run | git-daemon-sysvinit git-doc git-el git-email
git-gui gitk gitweb git-cvs git-mediawiki git-svn gdbm-l10n krb5-doc
krb5-user libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal
libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql keychain
libpam-ssh monkeysphere ssh-askpass ed diffutils-doc perl-doc
libterm-readline-gnu-perl | libterm-readline-perl-perl make
The following NEW packages will be installed:
ca-certificates git git-man krb5-locales less libasn1-8-heimdal libbsd0
libcurl3-gnutls libedit2 liberror-perl libexpat1 libgdbm-compat4 libgdbm5
libgssapi-krb5-2 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal
libheimntlm0-heimdal libhx509-5-heimdal libk5crypto3 libkeyutils1
libkrb5-26-heimdal libkrb5-3 libkrb5support0 libldap-2.4-2 libldap-common
libnghttp2-14 libperl5.26 libpsl5 libroken18-heimdal librtmp1 libsasl2-2
libsasl2-modules libsasl2-modules-db libsqlite3-0 libssl1.0.0 libssl1.1
libwind0-heimdal libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6
libxmuu1 multiarch-support netbase openssh-client openssl patch perl
perl-modules-5.26 publicsuffix xauth
0 upgraded, 54 newly installed, 0 to remove and 12 not upgraded.
Need to get 18.9 MB of archives.
After this operation, 103 MB of additional disk space will be used.
Err:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 multiarch-support amd64 2.27-3ubuntu1
Temporary failure resolving '[archive.ubuntu.com](http://archive.ubuntu.com/)'
Err:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 libxau6 amd64 1:1.0.8-1
Temporary failure resolving '[archive.ubuntu.com](http://archive.ubuntu.com/)'

Could you please help me in understanding what I am doing wrong?

I found a solution.

First of all, I think that this is probably a network error. Therefore, I made sure that I was not working with my VPN on. Then I tried few solutions but nothing worked. Therefore, I restarted my computer and tried again.
Since Docker works with caches (look here for some information) when I was running the Dockerfile, Docker was using the cache and was not giving any errors at the RUN apt-get update but it was Unable to locate package git

Therefore I did
docker system prune -a
that forced docker to clean the cache and then it finally worked.

I hope this helps someone else.