Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to start something based on ubuntu:xenial but apt-get not working
most strange in my case that any command for buzybox like nslookup, ping gateway and so on, working fine.
Can anybody advice for me? How to fix this issue inside docker container?
Specify DNS servers for Docker
The default location of the configuration file is /etc/docker/daemon.json. You can change the location of the configuration file using the --config-file daemon flag. The documentation below assumes the configuration file is located at /etc/docker/daemon.json.
Create or edit the Docker daemon configuration file, which defaults to /etc/docker/daemon.json file, which controls the Docker daemon configuration.
$ sudo nano /etc/docker/daemon.json
Add a dns key with one or more IP addresses as values. If the file has existing contents, you only need to add or edit the dns line.
{
"dns": ["8.8.8.8", "8.8.4.4"]
}
If your internal DNS server cannot resolve public IP addresses, include at least one DNS server which can, so that you can connect to Docker Hub and so that your containers can resolve internet domain names.
Save and close the file.
Restart the Docker daemon.
$ sudo service docker restart
Verify that Docker can resolve external IP addresses by trying to pull an image:
$ docker pull hello-world
If necessary, verify that Docker containers can resolve an internal hostname by pinging it.
$ docker run --rm -it alpine ping -c4 <my_internal_host>
PING google.com (192.168.1.2): 56 data bytes
64 bytes from 192.168.1.2: seq=0 ttl=41 time=7.597 ms
64 bytes from 192.168.1.2: seq=1 ttl=41 time=7.635 ms
64 bytes from 192.168.1.2: seq=2 ttl=41 time=7.660 ms
64 bytes from 192.168.1.2: seq=3 ttl=41 time=7.677 ms
Here is mine with my local dns.
Code:
{
"dns": ["192.168.1.2", "8.8.8.8", "8.8.4.4"]
}
Last edited by jmgibson1981; 11-15-2020 at 11:41 AM.
Thank you, jmgibson1981, for answer
But in docker documentation I don't see anything information about file /etc/docker/daemon.json
I see documentation about file /etc/default/docker
Of course I tune this file and set up DNS in this file
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns 8.8.8.8 --dns 1.1.1.1"
also DNS information can be set for each container creation, I use portainer, and in portainer I see overriding DNS parameters for each container creation
in my case /etc/docker/ now contains file key.json
However, I try you idea - add additional DNS definition and restart docker.
Unfortunately nothing changing....
In my case Hello-world docker working correctly, Portainer working correctly, even Busybox working absolutely correctly (any network utilities working fine), only Ubuntu don't working at all. In CentOS in my case working only ping.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.