Skip to content

Latest commit

 

History

History
67 lines (44 loc) · 4.43 KB

README.md

File metadata and controls

67 lines (44 loc) · 4.43 KB

Alpine-Kubernetes base image

CircleCI

The Alpine-Kubernetes base image enables deployment of Alpine Linux micro-service containers in Kubernetes, Consul, Tutum or other Docker cluster environments that use DNS-based service discovery and rely on the containers being able to use the search domains from resolv.conf for resolving service names.

About

Alpine-Kubernetes is based on the official Docker Alpine image adding the excellent s6 supervisor for containers and go-dnsmasq DNS server. Both s6 and go-dnsmasq introduce very minimal runtime and filesystem overhead.
Trusted builds are available on Docker Hub.


Imagelayers Docker Pulls

Motivation

Alpine Linux does not support the search keyword in resolv.conf. This absolutely breaks things in environments that rely on DNS service discovery (e.g. Kubernetes, Tutum.co, Consul). Additionally Alpine Linux deviates from the well established pardigm of always querying the primary DNS server first. This introduces problems in cases where the host is configured with multiple nameserver with inconsistent records (e.g. one Consul server and one recursing server).

To overcome these issues the Alpine-Kubernetes base image embeds a lightweight (1.2 MB) local DNS server that replicates GNU libc's resolver logic and enables processes running in the container to properly resolve service names.

How it works

The embedded DNS server acts as the nameserver for processes running in the container. On container start it parses the nameserver and search entries from the containers /etc/resolv.conf and configures itself as the nameserver for the container. It answers DNS queries according to the following conventions:

  • The nameserver listed first in resolv.conf is the primary server. It is always queried first.
  • Hostnames are qualified by appending the domains configured by the search keyword in resolv.conf
  • Single-label hostnames (e.g.: "redis-master") are always qualified with search domain paths
  • Multi-label hostnames are first tried as absolute names and only qualified with search paths if this does not yield results from the upstream server

Usage

Building your own image based on Alpine-Kubernetes is as easy as typing
FROM janeczku/alpine-kubernetes.
The official Alpine Docker image is well documented, so check out their documentation to learn more about building micro Docker images with Alpine Linux.

The small print:
Do NOT redeclare the ENTRYPOINT in your Dockerfile as this is reserved for S6's init script.

Example Alpine Redis image

FROM janeczku/alpine-kubernetes:3.2
RUN apk-install redis
CMD ["redis-server"]

Docker Hub image tags

Alpine-Kubernetes image tags follow the official Alpine Linux image. To build your images with the latest version of Alpine-Kubernetes that is based on Alpine Linux 3.2 use:

FROM janeczku/alpine-kubernetes:3.2

Each release build is also statically tagged with <Alpine Linux image version>-<Alpine-Kubernetes build number>, e.g.: 3.2-34.

DNS server configuration (optional)

Configuration of the DNS server can be adjusted by providing environment variables either at runtime with docker run -e ... or from within the Dockerfile. Check out the documentation for go-dnsmasq to find out what configuration options are available.

Acknowledgement