问题
I have a Rails application that I want to deploy using Docker on an Ubuntu server. I have the Dockerfile for the application already set up, right now I want to view the nginx
conf in its container.
I ran the command below to start an nginx
container in an interactive mode:
docker run -i -t nginx:latest /bin/bash
Right now I am trying to install nano
editor in order to view the configuration for nginx
configuration (nginx.conf
) using the commands below:
apt-get update
apt-get install nano
export TERM=xterm
However, when I run the first command apt-get update
, I get the error below:
Err:1 http://security.debian.org/debian-security buster/updates InRelease
Temporary failure resolving 'security.debian.org'
Err:2 http://deb.debian.org/debian buster InRelease
Temporary failure resolving 'deb.debian.org'
Err:3 http://deb.debian.org/debian buster-updates InRelease
Temporary failure resolving 'deb.debian.org'
Reading package lists... Done
W: Failed to fetch http://deb.debian.org/debian/dists/buster/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/debian-security/dists/buster/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/buster-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.
I have checked very well it has nothing to do with network connectivity. I would need some help. Thank you.
回答1:
I simply restarted docker and this worked for me.
sudo service docker restart
Prior to bumping into this issue, docker was working fine. If you never had docker working in the first place, you probably have a different issue.
回答2:
Here's how I solved it:
Start the docker container for the application in an interactive mode, in my case it an nginx
container :
docker run -i -t nginx:latest /bin/bash
Run the command below to grant read
permission to the others
role for the resolv.conf
file:
chmod o+r /etc/resolv.conf
Note: If you are having this issue on your host machine (Ubuntu Linux OS) and not for the Docker containers, then run the same command adding sudo
to it in the host machine terminal:
sudo chmod o+r /etc/resolv.conf
Endeavour to exit your bash interactive terminal once you run this:
exit
And then open a new bash interactive terminal and run the commands again:
apt-get update
apt-get install nano
export TERM=xterm
Everything should work fine now.
Reference to this on Digital Ocean: Apt error: Temporary failure resolving 'deb.debian.org'
That's all.
I hope this helps
回答3:
If you have VPN running, stop it and try again. It solved for me!
回答4:
I easily resolved it via:
- docker exec -it nginx bash (Go inside container)
- ping google.com (if not working)
- exit (Exit from container)
- sudo service docker restart
Please also confirms /etc/sysctl.conf
- net.ipv4.ip_forward = 1
sudo sysctl -p /etc/sysctl.conf
回答5:
I had a similar issue, I tried many suggested solutions, but my issue was gone after I rebooted y VM.
来源:https://stackoverflow.com/questions/61567404/docker-temporary-failure-resolving-deb-debian-org