Docker with a new nameserver

后端 未结 2 885
广开言路
广开言路 2021-01-24 23:04

How I can add new nameserver in /etc/resolv.conf (dockerfile)?

On my dockerfile I use:

FROM ubuntu:14.04

RUN echo \"nameserver 10.111.122.1         


        
2条回答
  •  北荒
    北荒 (楼主)
    2021-01-24 23:36

    So, one of the ways you can add new DNS information to your container's build process is by adding some startup options to your Docker daemon. The documentation for that process reveals that the option you'll use is --dns. The location of your configuration file depends on your specific distro. On my Linux Mint machine, the file is in /etc/default/docker. On Linux Mint, look for the DOCKER_OPTS= line, and add the appropriate --dns=x.x.x.x entries to that line.

    For example, if you want to use Google's DNS, you should change that line to look like this:

    DOCKER_OPTS="--dns=8.8.4.4 --dns=8.8.8.8"
    

    Additionally, in the absense of --dns or --dns-search startup options, Docker will use the /etc/resolv.conf of the host it's running on instead.

提交回复
热议问题