This page looks best with JavaScript enabled

Common Problems When Using Alpine Images

 ·  ☕ 1 min read

1. DNS Request Timeout

Cause: alpine uses the musl library, which has some limitations in DNS resolution [1]

Solution:

Do not use an apline image, and add the options single-request-reopen setting to the container’s resolv.conf file. This is because the single-request-reopen option only takes effect for the glibc library, while apline images use the musl library.

2. Unable to Resolve hosts under Docker

Cause:

alpine has no /etc/nsswitch.conf, so processes that depend on hosts cannot resolve hosts.

Solution:

Add the following command in the Dockerfile:

1
RUN if [ ! -e /etc/nsswitch.conf ];then echo 'hosts: files dns' > /etc/nsswitch.conf; fi

3. References

  1. https://wiki.musl-libc.org/functional-differences-from-glibc.html#Name-Resolver/DNS

WeChat Official Account
WRITTEN BY
WeChat Official Account