# Using custom DNS servers inside a container

**URL:** <https://forums.balena.io/t/using-custom-dns-servers-inside-a-container/199554>\
**Category:** Project help\
**Tags:** docker\
**Created:** [October 15, 2020, 7:26am UTC](https://forums.balena.io/t/using-custom-dns-servers-inside-a-container/199554 "2020-10-15T07:26:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![proffalken](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@proffalken](https://forums.balena.io/u/proffalken)\
**Post date:** [October 15, 2020, 7:26am UTC](https://forums.balena.io/t/using-custom-dns-servers-inside-a-container/199554/1 "2020-10-15T07:26:12Z")

</div>

Hey all,

I’ve written a project to take data from a [lightwaverf energy monitor](https://lightwaverf.com/products/jsjslw600-lightwaverf-electricity-monitor-and-energy-monitor) and display it on a Grafana dashboard so I know how much electricity I’m using.

The full code is available on [Github](https://github.com/proffalken/lightwaveEnergy2influx) and it’s working really well as long as I don’t try and use the DNS entries from my local network.

[My setup is fairly unique](https://www.mockingbirdconsulting.co.uk/blog/2019-01-05-hashicorp-at-home/), however I need to point the container at a local DNS server so it can resolve the services inside the local network instead of relying on IP addresses and port numbers.

Is there an easy way to do this rather than having to edit the SD Card data before I boot, or without running a multi-container setup?

Thanks in advance,

Matt

P.S. This is what the dashboard looks like:

 ![Energy](https://global.discourse-cdn.com/balena/original/2X/b/b716a8abc453824b7e18b0147a74d68d1465a78a.png)

---

<div class="post-metadata">

**Author:** ![thundron](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thundron/32/1379_2.png) [@thundron](https://forums.balena.io/u/thundron)\
**Post date:** [October 15, 2020, 9:53am UTC](https://forums.balena.io/t/using-custom-dns-servers-inside-a-container/199554/4 "2020-10-15T09:53:06Z")

</div>

Hi,

Did you already try the solution described in the paragraph here [https://www.balena.io/docs/learn/develop/runtime/#using-dns-resolvers-in-your-container](https://www.balena.io/docs/learn/develop/runtime/#using-dns-resolvers-in-your-container) to see if it solves your issue?

---

<div class="post-metadata">

**Author:** ![proffalken](https://avatars.discourse-cdn.com/v4/letter/p/439d5e/32.png) [@proffalken](https://forums.balena.io/u/proffalken)\
**Post date:** [October 15, 2020, 10:13am UTC](https://forums.balena.io/t/using-custom-dns-servers-inside-a-container/199554/6 "2020-10-15T10:13:59Z")

</div>

That’s not the issue here, I’m not running a resolver inside the container itself, I need the container to use a resolver on the local network so it can perform local lookups.

---

<div class="post-metadata">

**Author:** ![karaxuna](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@karaxuna](https://forums.balena.io/u/karaxuna)\
**Post date:** [October 15, 2020, 11:03am UTC](https://forums.balena.io/t/using-custom-dns-servers-inside-a-container/199554/8 "2020-10-15T11:03:11Z")

</div>

Hi,

According to this [SO answer](https://stackoverflow.com/a/44410303/1265753) you can have `dns` property inside `/etc/docker/daemon.json`:

```auto
{"dns": ["your_dns_server_ip"]}

```

Copy `daemon.json` file to image like it’s done [here](https://github.com/balena-io-playground/balena-dind/blob/master/Dockerfile.aarch64#L10):

```auto
COPY daemon.json /etc/docker/daemon.json

```

Please try this and let us know how it goes.
