Name resolution
Introduction
DNS sucks in docker. However, there are two fixes.
Fix no. 1
Create /etc/docker/daemon.json:
{
"dns": ["192.168.1.2", "192.168.1.25"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker run --rm alpine sh -c "cat /etc/resolv.conf && nslookup hfile.simmy.org"
Fix no. 2
Edit etc/default/docker
# Here in Debian, this file is sourced by:
# - /etc/init.d/docker (sysvinit)
# - /etc/init/docker (upstart)
# - systemd's docker.service
# Use of this file for configuring your Docker daemon is discouraged.
# The recommended alternative is "/etc/docker/daemon.json", as described in:
# https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file
# If that does not suit your needs, try a systemd drop-in file, as described in:
# https://docs.docker.com/config/daemon/systemd/
# Docker Upstart and SysVinit configuration file
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
# Please see the documentation for "systemd drop-ins":
# https://docs.docker.com/engine/admin/systemd/
#
# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"
# Use DOCKER_OPTS to modify the daemon startup options.
DOCKER_OPTS="--dns=192.168.1.2 --dns 192.168.1.25"
# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"
DOCKER_OPTS="--dns=192.168.1.2 --dns 192.168.1.25"
It's mandatory to keep this DNS configuration up to date. Otherwise NPM will not be able to resolve internal addresses.
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker run --rm alpine sh -c "cat /etc/resolv.conf && nslookup hfile.simmy.org"
No Comments