docker-dnsmasq icon indicating copy to clipboard operation
docker-dnsmasq copied to clipboard

No ability to import more config files

Open naveci opened this issue 7 years ago • 4 comments

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

naveci avatar Feb 07 '18 09:02 naveci

I've never tried it, though does mounting a new hosts file work:

  -v /opt/hosts:/etc/hosts

?

jpillora avatar Feb 07 '18 22:02 jpillora

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.

naveci avatar Feb 10 '18 23:02 naveci

Is there a Solution?

FlyingEagle avatar May 11 '20 15:05 FlyingEagle

I added in blacklisting by doing the following:

  1. Add directory config directive to the dnsmasq.conf:
conf-dir=/etc/dnsmasq.d/
  1. 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/
  1. Add a blacklisit.conf. I generated mine from https://pgl.yoyo.org/as/

franciswertz avatar Mar 15 '22 03:03 franciswertz