Fix: apt-get update hanging within Ubuntu Docker container

I experienced this issue in a Docker container, hanging at this point:

Step 5/24 : RUN apt-get update && apt-get install -y --no-install-recommends         cuda-cudart-$CUDA_PKG_VERSION         cuda-compat-10-1 &&     ln -s cuda-10.1 /usr/local/cuda &&     rm -rf /var/lib/apt/lists/*
 ---> Running in 3cb10279744e
Ign:1 stretch InRelease
Get:2 stretch/updates InRelease [94.3 kB]
Get:3 stretch-updates InRelease [91.0 kB]
Get:4 stretch Release [118 kB]
Get:5 stretch Release.gpg [2434 B]
Get:6 stretch-updates/main amd64 Packages [11.1 kB]
Get:7 stretch/updates/main amd64 Packages [485 kB]
Get:8 stretch/main amd64 Packages [7084 kB]

Strace showed it waiting on data from a socket:

$ ps -faux|less|grep docker-compose
testuser  8098  0.4  0.4 115644 39016 pts/0    S+   08:56   0:00  |                   \_ /usr/bin/python3 /usr/local/bin/docker-compose build app
testuser  8402  0.0  0.0  13136  1084 pts/1    S+   08:59   0:00              \_ grep docker-compose
$ sudo strace -fp 8098
strace: Process 8098 attached

I narrowed down the issue to a https apt sources.list entry I had added and the fix was to install the following packages before that sources update:

apt-get install -y --no-install-recommends gnupg2 curl ca-certificates apt-transport-https

One thought on “Fix: apt-get update hanging within Ubuntu Docker container

Leave a Reply

Your email address will not be published. Required fields are marked *