Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel container can not resolve dns #540

Closed
Ulli2k opened this issue Dec 4, 2019 · 5 comments
Closed

Parallel container can not resolve dns #540

Ulli2k opened this issue Dec 4, 2019 · 5 comments

Comments

@Ulli2k
Copy link

Ulli2k commented Dec 4, 2019

I have successfully installed pi hole in my docker environment by the provided docker-compose. Due to my ubuntu system I also followed the ubuntu procedure about resolve.conf.

This is a Issue trying to run the docker image

Description

Parallel docker container which are using the internet/DNS resolution are not working.
If I try to resolve an DNS on the basis system...outside of any container it works.
But inside of any container it is not working.
On all my other devices/computer the dns resolution works fine so far.

I have tried destroying my container instance, pulling the newest image version, and re-creating a new container
I have tried running without my volume data mounts to eliminate volumes as the cause
I have searched this repository for existing issues and pull requests that look similar

Context and extra information

Your Environment

  • Docker Host Operating System and OS Version: ubuntu current lts
  • Docker Version:
  • Hardware architecture: x86
@jokaorgua
Copy link

I have the same issue on Raspberry PI 4

@conrad82
Copy link

Did you find any solutions?

@edgd1er
Copy link
Contributor

edgd1er commented Feb 11, 2021

Hi All,

May be the setup you have, is the same I have.
I'm running on my Rpi 4, next to the pihole container, containers that need dns resolution ( socks5 server, yacht, watchtower, ..).
I need those containers to have a proper dns resolution and it seems that docker is not good at it when the dns server is amongst its containers.
Her is my solution:
for each container

  • attached the container to pihole's network
  • add a dns that is pihole's net gateway ( docker network inspect | grep -i gateway )

as a result I add in the docker-compose of each container that needs dns resolution:

services:
 service1:
    ......
    networks:
      - pihole_net
    dns:
      - 172.27.0.1

networks:
  pihole_net:
    external: true

I hope it helps.

@conrad82
Copy link

conrad82 commented Feb 13, 2021

@edgd1er , thank you!

That worked for me!

I was a bit lazy, so I have not created a pihole_net network.
I used the default docker-compose network gateway, docker network inspect <default network> | grep -i gateway.
I did a reboot to see if it changed, it seemed to be persistent across a single reboot at least

I also tried

dns:
      - 1.1.1.1

which also works, for the superlazy - but it then bypasses pihole.

In summary, in my single docker-compose.yml with pihole and other containers, I

  1. Found the docker gateway ip address in accordance with solution from @edgd1er
  2. Added following to .env file: GATEWAY=172.18.0.1 # sudo docker network inspect docker-server_default | grep -i gateway
  3. For containers requiring internet, I added
    dns:
      - $GATEWAY

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants