Docker Tips: Difference between revisions

From NIEF Wiki
Jump to navigation Jump to search
(Created page with "Hardcode DNS server in docker daemon.json Edit /etc/docker/daemon.json { "dns": ["10.1.2.3", "8.8.8.8"] } Restart the docker daemon for those changes to take...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
Hardcode DNS server in docker daemon.json
== Intro ==
This just has a handful of frequently encountered issues we have had with docker deploys that are worth noting in case they happen to others.
 
== Docker Storage ==
Sometimes Docker doesn't seem to release file system records correctly and can fill an entire file system, but a simple reboot of the computer may fix things.  Possible it may be necessary to do execute the following command:
 
    docker system prune
 
== Docker DNS Failure ==
It appears that sometimes docker containers can lose the ability to resolve domain names.  We haven't identified an exact cause for this or even for certain if the following is a consistent fix for it, but it is worth trying. Hardcode DNS server information in the docker config file ''daemon.json'' located in ''/etc/docker''.  You would replace ''#.#.#.#'' with the IP address of your local DNS server:
    {
Edit /etc/docker/daemon.json
        "dns": ["#.#.#.#", "8.8.8.8"]
    }
 
Typically the above would require a reboot or at least a complete restart of docker.
 
Note that you can also add dns to the docker-compose file, just add a section with all DNS servers listed by IP address (this may be a good best practice, but it also seems like it reduces portability of a configuration):
 
    dns:
      - 192.168.3.7
      - 192.168.111.1
      - 192.168.10.5
      - 192.168.10.15


It actually looks like when/if DNS fails that restarting the docker daemon without rebooting works, and in the case of Texas DPS, it appears DNS never works after a reboot, but restarting the docker daemon seems to work.
{
    "dns": ["10.1.2.3", "8.8.8.8"]
}


== Random System Errors ==
On Linux servers there are lots of different docker versions available via different packages.  It is very easy to end up with a version that is prone to bugs.  Make every effort to run a docker-ce version released by [https://docs.docker.com/get-docker/ docker] as opposed to a version in a package maintained by others.
Restart the docker daemon for those changes to take effect:
sudo systemctl restart docker
Now when you run/start a container, docker will populate /etc/resolv.conf with the values from daemon.json

Latest revision as of 22:06, 21 July 2022

Intro

This just has a handful of frequently encountered issues we have had with docker deploys that are worth noting in case they happen to others.

Docker Storage

Sometimes Docker doesn't seem to release file system records correctly and can fill an entire file system, but a simple reboot of the computer may fix things. Possible it may be necessary to do execute the following command:

    docker system prune

Docker DNS Failure

It appears that sometimes docker containers can lose the ability to resolve domain names. We haven't identified an exact cause for this or even for certain if the following is a consistent fix for it, but it is worth trying. Hardcode DNS server information in the docker config file daemon.json located in /etc/docker. You would replace #.#.#.# with the IP address of your local DNS server:

    {
        "dns": ["#.#.#.#", "8.8.8.8"]
    } 

Typically the above would require a reboot or at least a complete restart of docker.

Note that you can also add dns to the docker-compose file, just add a section with all DNS servers listed by IP address (this may be a good best practice, but it also seems like it reduces portability of a configuration):

   dns:
     - 192.168.3.7
     - 192.168.111.1
     - 192.168.10.5
     - 192.168.10.15

It actually looks like when/if DNS fails that restarting the docker daemon without rebooting works, and in the case of Texas DPS, it appears DNS never works after a reboot, but restarting the docker daemon seems to work.

Random System Errors

On Linux servers there are lots of different docker versions available via different packages. It is very easy to end up with a version that is prone to bugs. Make every effort to run a docker-ce version released by docker as opposed to a version in a package maintained by others.