Jeremy
Jeremy

Reputation: 3548

`apt-get update` never completes in Docker build

Any Dockerfile I try to build, that includes apt-get update, just hangs indefinitely.

I can launch an image and run apt-get update inside the image with no problems.

docker run -it --entrypoint bash node:lts-bullseye
root@7b6ea3487aef:/# apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main arm64 Packages [120 kB]
Get:5 http://deb.debian.org/debian bullseye/main arm64 Packages [8070 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [2596 B]
Fetched 8392 kB in 2s (4936 kB/s)
Reading package lists... Done
root@7b6ea3487aef:/#

But if it's during the Docker build, it just hangs!

Update -
I installed lima and I'm able to build the image fine with -
lima nerdctl build .

So I think this must be Docker related

Dockerfile is nothing special - this is enough to reproduce the issue -

FROM node:lts-buster-slim
RUN apt-get update

Upvotes: 4

Views: 2914

Answers (2)

Damir Nafikov
Damir Nafikov

Reputation: 332

Tried just restarting docker and os - not worked (still too long + apt-get install -y build-essential failed + pip install failed), but adding in build the network as host solved problem:

services:
  app:
    build:
      context: .
      network: host

or docker build --network host

Source: https://stackoverflow.com/a/66714888/11285211

Upvotes: 3

Jeremy
Jeremy

Reputation: 3548

"Hello, have you tried turning it off and on again"?

I just needed to restart the docker daemon.

Upvotes: 3

Related Questions