How to set custom DNS for alpine images on CircleCI

You may want to use a custom DNS on an Alpine image due to networking issues or if you have a preferred DNS provider. This guide will help you to set the DNS when using an Alpine image while using CircleCI. 

Instructions

You can use the following echo command to set the nameserver to 8.8.8.8 but this can be set to any DNS server. If you would like to have multiple you will need to add another \nnameserver x.x.x.x with your preferred DNS settings after the nameserver section.

steps:
- run: cat /etc/resolv.conf
- run: echo -e "search ec2.internal\nnameserver 8.8.8.8\noptions ndots:0" > /etc/resolv.conf
- run: cat /etc/resolv.conf

Outcome

Once this has been set your DNS requests will use the DNS servers that you have set on the /etc/resolv.conf file.

Additional Resources

The following support article is about how to set custom DNS on Ubuntu:

https://support.circleci.com/hc/en-us/articles/7323511028251-How-to-set-custom-DNS-on-Ubuntu-based-images-using-netplan

The following link is the official Alpine Linux networking link:

https://wiki.alpinelinux.org/wiki/Configure_Networking

Was this article helpful?
0 out of 2 found this helpful

Comments

0 comments

Article is closed for comments.