Open naveci opened 6 years ago
I've never tried it, though does mounting a new hosts file work:
-v /opt/hosts:/etc/hosts
?
Sadly no, I get an error that happens more often when I've tried to connect a directory:
Recreating dnsmasq ... error
ERROR: for dnsmasq Cannot start service dnsmasq: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"rootfs_linux.go:58: mounting \\\"/opt/hosts\\\" to rootfs \\\"/var/lib/docker/overlay/773eb0e23d3f27f4a637a917ee275f8400355ea9e521b0f8486c27c43b21a1fc/merged\\\" at \\\"/var/lib/docker/overlay/773eb0e23d3f27f4a637a917ee275f8400355ea9e521b0f8486c27c43b21a1fc/merged/etc/hosts\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for dnsmasq Cannot start service dnsmasq: OCI runtime create failed: container_linux.go:296: starting container process caused "process_linux.go:398: container init caused \"rootfs_linux.go:58: mounting \\\"/opt/hosts\\\" to rootfs \\\"/var/lib/docker/overlay/773eb0e23d3f27f4a637a917ee275f8400355ea9e521b0f8486c27c43b21a1fc/merged\\\" at \\\"/var/lib/docker/overlay/773eb0e23d3f27f4a637a917ee275f8400355ea9e521b0f8486c27c43b21a1fc/merged/etc/hosts\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
OS = CentOS. Problem only occurs with this container, so I'm not sure whether it has to do with the Dockerfile or something else is at play.
Is there a Solution?
I added in blacklisting by doing the following:
1) Add directory config directive to the dnsmasq.conf
:
conf-dir=/etc/dnsmasq.d/
2) Add a volume mapping for this directory. In my case my home container server this is located at /opt/dnsmasq/
-v /opt/dnsmasq/conf.d:/etc/dnsmasq.d/
3) Add a blacklisit.conf
. I generated mine from https://pgl.yoyo.org/as/
Hey,
Great project. I really enjoy the container, but I've been unable so far to add extra hostfiles. By simple redirecting the whole directory (instead of only the config file) breaks everything. And so does every other solution I've tried.
My goal is to have auto-updating DNS blocking lists which I update on the host and are linked in the Docker container. https://github.com/notracking/hosts-blocklists is a good example of such a list. It takes some of the performance hit away from my firewall.
Kind regards