dns configuration option does not work on docker-compose==1.6.0
Step 1:
$ cat docker-compose.yml
version: "2"
services:
testnet:
image: fedora:23
dns: 192.168.1.1
command: /bin/bash
Step 2:
$ docker-compose -f docker-compose.yml run testnet
Step 3:
[root@bbd9f61098fb /]# cat /etc/resolv.conf
search xxx.yyy.tld
nameserver 127.0.0.11
options ndots:0
As you can see, dns option is ignored by docker-compose and some garbage is set instead. This prevents my containers from starting up because they require to use mentioned DNS server. BTW, what kind of shit is 127.0.0.11, and how it get to resolve.conf?
With version 1 of yaml file everything is working as expected (nameserver is set correctly).
This seems to be an issue with docker/docker (https://github.com/docker/docker/issues/20101), but we need more information to be able to triage it. It doesn't reproduce for me either.
If you could provide more information to https://github.com/docker/docker/issues/20101 about your environment (Host OS, docker info, cat /etc/resolv.conf, etc) that would help get the issue resolved.
127.0.0.11 is a loopback IP address. It is used by the embedded docker DNS server.
@mmarzantowicz also pls confirm if you are using fedora/centos/RHEL ?
If yes, we have a known issue and the workaround is to disable firewalld.
@mmarzantowicz btw, if you can read about the embedded-DNS server (since you seem to be interested in knowing about 127.0.0.11 :) ) : https://github.com/docker/docker/blob/ef52a53c34d9f128d9435d031442509837c25c02/docs/userguide/networking/dockernetworks.md#docker-embedded-dns-server
@mavenugo , my host OS is Arch Linux and only guests are on Fedora or anything RH-based. I do not have any firewalls enabled so docker rules. I now understand how DNS works but it looks like I have different connectivity issue to solve than I primarily thought. Thanks for your comments.
I'm closing this issue as I'm no longer able to reproduce this bug. I'm not sure why some apps in container were complaining about DNS server at 127.0.0.11. I'll reopen this issue in case I find it possible to reproduce mentioned failure again.
Thanks for all your support.
I have the exact same problem. When starting the container with docker run --dns it works perfectly. When I set the dns in the docker-compose the resolv.conf on the container is not updated...
docker compose file
version: '2'
services:
app:
image: toto
container_name: toto
restart: always
hostname: toto.example.org
dns:
- 192.168.1.1
ports:
- "8000:80"
volumes:
- "/etctoto:/etc/toto"
logging:
driver: syslog
options:
syslog-tag: "{{.Name}}.{{.ID}}"
docker-compose v1.6 docker info :
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 4
Server Version: 1.10.2
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 66
Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: bridge null host
Kernel Version: 3.13.0-24-generic
Operating System: Ubuntu 14.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.798 GiB
Name: node02
ID: XNGO:L6KC:FGXE:T34M:2K4H:MTTL:WL6V:VOAQ:THV7:YFCG:3ZGP:N5WA
WARNING: No swap limit support
Please, reopen this. I also can confirm this issue on Ubuntu 14.04. Restarting Docker service is what solves the issue.
@ernetas, please check your issue is not related to one mentioned by @dnephin in response to my original post. I'm not aware of what version of docker/docker-compose are you having issues with on Ubuntu but it already might have been fixed upstream.
I investigate on my side and I found my problem. I cannot speak for everybody but here is what I found:
Setting the property: net: "host" in the docker-compose file or --net host in the docker run command will result in the ports not displayed when doing a docker ps. It is normal because setting this property let the container inherits the host network settings.
As per documentation, this configuration is not recommend so I change it to: net: "bridge" (default if not specified) and added a DNS on my docker host to solve my communication problems.
I am on CentOS 7 and I have this problem. I am on docker-compose 1.7.1 and Docker 1.11.1.
dns: 8.8.8.8 is not added into /etc/resolv.conf at all and I am not able to add any host to /etc/hosts as well by linking some other service. I have custom bridge network.
I have three compose files and I am doing it like docker-compose -f first.yml -f second.yml -f third.yml up -d.
I checked that these services are started in order so the target container I want to add a link for is the last one in the starting chain.
I tried to add external_link but without success as well.
I am not completely sure what is wrong but I am not able to add e.g. dns record to /etc/hosts at all even I am using just docker-compose up -d on a single docker-compose.yml with one service.
I am trying to setup nexus repo:
version: '2'
services:
nexus:
hostname: nexus
domainname: somedomain.net
container_name: nexus
image: sonatype/nexus:oss
networks:
server-net:
ipv4_address: 172.19.0.7
ports:
- "8081:8081"
volumes:
- /srv/docker/nexus/nexus-data:/sonatype-work
dns:
- 8.8.8.8
dns_search:
- somedomain.net
environment:
- MAX_HEAP=768m
networks:
server-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.19.0.0/24
gateway: 172.19.0.1
I have verified that it works with --dns flag on normal docker run
docker run -d -p 8081:8081 \
--name nexus \
--dns 8.8.8.8 \
sonatype/nexus
However, it does not work when I create a network manually like this:
docker network create server-net
docker run -d -p 8081:8081 \
--name nexus \
--net server-net \
--dns 8.8.8.8 \
sonatype/nexus
In this case, it is not there. Very interesting ... Why specifying network prevents me from adding DNS record to /etc/hosts?
+1 same issue for me
How to slove dns problem when using docker-compose ? When i changed dns in /etc/resolv.conf - every links to other containers not working.
Install dnsmasq on the host and you should be alright and put the container to net: bridge.
This issue is a critical one, please open it ASAP. Without ability to properly define DNS, compose is a harming manner, especially on production. Please consider removing 1.6 until problem is not fixed.
DNS is configured differently when using a custom network (as is the case when using v2 of the Compose file format), but the dns setting is still respected. From the Docker networking docs:
The IP addresses passed via the
--dnsoption is used by the embedded DNS server to forward the DNS query if embedded DNS server is unable to resolve a name resolution request from the containers. These--dnsIP addresses are managed by the embedded DNS server and will not be updated in the container's/etc/resolv.conffile.
You can be right if DNS are down by docker's bug: https://github.com/docker/docker/issues/11407 But I'll wait till this one is resolved and then try again.
Till then docker, so long, and thanks for all the fish...
Anyone found a fix for this?
No fix, you need to change host dns network settings to get a result.
I had the same problem under docker-compose 1.11. Solved adding network_mode to the yaml configuration.