# Name resolution

## Introduction

DNS sucks in docker. However, there are two fixes.

## Fix no. 1

Create `/etc/docker/daemon.json`:

```ini
{
  "dns": ["192.168.1.2", "192.168.1.25"]
}
```

```bash
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker run --rm alpine sh -c "cat /etc/resolv.conf && nslookup hfile.simmy.org"
```

<span style="color: rgb(34, 34, 34); font-family: var(--font-heading, var(--font-body)); font-size: 2.8275em;">Fix no. 2</span>

Edit etc/default/docker

```ini
# 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"
```

<p class="callout info">DOCKER\_OPTS="--dns=192.168.1.2 --dns 192.168.1.25"</p>

<p class="callout warning">It's mandatory to keep this DNS configuration up to date. Otherwise NPM will not be able to resolve internal addresses.</p>

```bash
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker run --rm alpine sh -c "cat /etc/resolv.conf && nslookup hfile.simmy.org"
```