I am having issues connecting with apt-get from a Docker image. To recreate, I can run
sudo docker run -it ubuntu /bin/bash
and then type:
apt-get update
Without fail, the machine is unable to connect and I get a series of errors that look like this:
Failed to fetch http://ports.ubuntu.com/ubuntu-ports/dists/focal/InRelease Could not connect to ports.ubuntu.com:80 (91.189.88.152), connection timed out
I am running an M1 Macbook Pro and have tried:
None of this has helped so far, and I have been completely unable to apt-get update
or apt-get install
to work in a docker container. Would greatly appreciate the help!
Check if you have Private Relay enabled. Disabling it solved for me, without factoring reset the MacBook Pro.
I had the same issue, where in Safari I could access http://ports.ubuntu.com
but in Chrome or even wget http://ports.ubuntu.com
was giving connection timeout
on Docker.
Figured out I was able to load these URLs in Safari, but not Chrome – which tracks with an ongoing issue I've had with this new computer where some sites weren't loading in Chrome. Do not know exactly what the issue was – probably some weird DNS thing – but a factory reset of my Mac solved the issue.
RUN apt-get update -y
Try to run this command and let me if it works
First make sure you can ping
to external services. May be try ping google.com
.
If its not working, check firewall of you laptop. It may be blocking apt
repo.
Alternately you can try two options. First using Dockerfile
and then docker build
FROM ubuntu
RUN apt update
RUN apt install vim #or any package you want
Or, run the docker image, and then connect to that image and run.
docker run --name my_ubuntu -d ubuntu
docker exec -it my_ubuntu /bin/bash
And then try to run apt update
command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.