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. 


You can use the following echo command to set the nameserver to 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.

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


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:

The following link is the official Alpine Linux networking link:

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



Article is closed for comments.