-
Notifications
You must be signed in to change notification settings - Fork 60
fix(dns): /etc/hosts was ignored by traefik #75
base: master
Are you sure you want to change the base?
Conversation
Fix traefik/traefik#6001 ### What does this PR do? It create the missing `/etc/nsswitch.conf`. ### Motivation During proxying, traefik is performing a DNS resolution. This DNS resolution is skipping `/etc/hosts` file. This can cause unwanted DNS resolution, especially when using hostname as fqdn in marathon. If you use `/etc/hosts` file for some resolution, this will fix it. If you use a real fqdn in marathon on a private network, you will still have to properly configure DNS serveur in traefik host.
Related to #42 |
I am curious, if this was already merged, why was it removed? |
No clue why travis get this: ---> Running in d7c16a0f1158
OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown
The command "./.ci/test.sh" exited with 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Build is failing on a
sh
error, because you updated a Docker image based onscratch
(ref. https://hub.docker.com/_/scratch), which does NOT contains any sh or bash shell, resulting in failure of executing anyRUN
command. Suggestions proposed to fix this. - Can you remove the comments, it's verbose and doesn't provide any value as all the history is kept in git and can be resolved with
git blame
- Can add the commands to the alpine image please?
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
What command are required in the alpine image ? It seems they already have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What command are required in the alpine image ? It seems they already have /etc/resolv.conf since you import them from another image.
- The
scratch
image copies files from thetraefik:v*-alpine
: there is a dependency so you must change the alpine change. - The
alpine
image is built first. It does not have anynsswitch.conf
file. So you have to create one. As Alpine has ash
binary within, you can totally use the sameRUN
command that you specified initially:RUN [ ! -e /etc/nsswitch.conf ] && echo "hosts: files dns" > /etc/nsswitch.conf
- Yes, there is already a file
/etc/resolv.conf
in the alpine image: this file is mounted by docker when container are run, providing the DNS resolvers to your container as explained in https://docs.docker.com/v17.09/engine/userguide/networking/default_network/configure-dns/ . Therefore this is out of the scope of your PR, since you request to use the/etc/hosts
files before trying DNS resolution.
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Thanks for providing all the details, I've updated the PR with requested change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you're almost there.
I've added some suggestions, as Traefik's version comes from an environment variable for the templates (because it changes over time and we don't update all occurences by hand).
Once you'll have fixed the templates, can you run the following command from the root of the repository to update the Dockerfile
s from templates please?
bash update.sh v2.1.1
Side question: what is the status of this feature request for the Windows Docker images? |
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Co-Authored-By: Damien Duportal <damien.duportal@gmail.com>
Hi @kopax , can you ensure that you're setting the parent image to |
Hi @dduportal too much time have passed since the traefik/traefik#6012 and I lost track of what is needed. What about the alpine image? Was this never fixed in recent traefik version? I am still running on 2.1.1 with this fix but perhaps it's time to close this? |
Fix traefik/traefik#6001
What does this PR do?
It create the missing
/etc/nsswitch.conf
.Motivation
During proxying, traefik is performing a DNS resolution. This DNS resolution is skipping
/etc/hosts
file. This can cause unwanted DNS resolution, especially when using hostname as fqdn in marathon.If you use
/etc/hosts
file for some resolution, this will fix it. If you use a real fqdn in marathon on a private network, you will still have to properly configure DNS serveur in traefik host.