• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

:octocat: Alpine Linux base image with support for DNS service discovery in Docker clusters

Deprecated: This image is no longer maintained as Alpine Linux 3.4+ supports search domains in resolv.conf.

Alpine-Kubernetes base image

CircleCI ImageLayers Size Docker Pulls License

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 ability to qualify service names using the search domains from resolv.conf.

Supported tags and respective Dockerfile links

Trusted builds are available on Docker Hub.

About

Alpine-Kubernetes is derived from the official Docker Alpine image adding the s6 supervisor for containers and a lightweight DNS resolver with minimal runtime and filesystem overhead.

Motivation

Alpine Linux does not support the search keyword in resolv.conf. This breaks many tools that rely on DNS service discovery (e.g. Kubernetes, Tutum.co, Consul).

Additionally Alpine Linux deviates from the established concept of primary and secondary nameservers. This leads to problems in cases where the container 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 includes a lightweight (1.2 MB) container-only DNS server that replicates the behavior of GNU libc's stub-resolver.

How it works

On container start the DNS resolver parses the nameserver and search entries from resolv.conf and configures itself as nameserver for the container. DNS queries from local processes are handled following these conventions:

  • The nameserver listed first in resolv.conf is always queried first. Additional nameservers are treated as fallbacks.
  • Hostnames are qualified by appending the domains configured with the search keyword in resolv.conf
  • Single-label hostnames (e.g.: "redis-master") are always qualified with search domains
  • Multi-label hostnames are first tried as absolute names and only then qualified with search domains

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 the supervisor init script.

Example Alpine Redis image

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

Caveats

Kubernetes multi-container pods

All containers within a pod behave as if they are on the same host with regard to networking. They can all reach each other’s ports on localhost.

(Source: Kubernetes Networking)

This means there can be only one container per pod running a DNS server on localhost. If your pod spec contains more than one containers based on the Alpine-Kubernetes base image, you need to disable the local DNS server for all but one of them. This can be achieved by setting the environment variable ALPINE_NO_RESOLVER. Any container set to this env var will use an existing DNS service on localhost as it's nameserver.

apiVersion: v1
kind: Pod
metadata:
  name: redis_django
  labels:
    app: web
spec:
  containers:
    - name: key-value-store           # On this container the DNS server will bind to localhost as usual
      image: alpine-kubernetes-redis
      ports:
        - containerPort: 6379
    - name: frontend                  # This container will just have it's nameserver set to localhost
      image: alpine-kubernetes-django
      ports:
        - containerPort: 8000
      env:
        - name: ALPINE_NO_RESOLVER
          value: True

Multiple processes in a single container (optional)

You can leverage s6 supervised services to run multiple processes in a single container. Instructions can be found here. Since the container DNS server itself is a service, any additional services need to be configured to start after the DNS service. This is accomplished by adding the following line to the service script:

if { s6-svwait -t 5000 -u /var/run/s6/services/resolver }

Example service script

#!/usr/bin/execlineb -P
if { s6-svwait -t 5000 -u /var/run/s6/services/resolver }
with-contenv
nginx

Docker Hub image tags

Alpine-Kubernetes image tags follow the official Alpine Linux image. See the top of this page for the currently available versions.

DNS resolver configuration (optional)

The configuration of the included go-dnsmasq DNS server can be changed by setting environment variables either at runtime with docker run -e ... or in the Dockerfile. Check out the documentation for the available configuration options.

Acknowledgement

More Repositories

1

calibre-web

📚 Web app for browsing, reading and downloading eBooks stored in a Calibre database
Python
11,592
star
2

go-dnsmasq

🐬 Lightweight caching DNS server/forwarder
Go
401
star
3

rancher-letsencrypt

🐮 Rancher service that obtains and manages free SSL certificates from the Let's Encrypt CA
Go
326
star
4

haproxy-acme-validation-plugin

🍀 Zero-downtime ACME / Let's Encrypt certificate issuing for HAProxy
Shell
293
star
5

docker-machine-vultr

Ⓜ️ Docker Machine driver for Vultr Cloud
Go
193
star
6

docker-dropbox

🐳 Dropbox in a Docker image. This works.
Shell
148
star
7

go-ipset

🔥 Go bindings for the IPtables ipset http://ipset.netfilter.org userspace utility
Go
119
star
8

keepalived-ingress-vip

💓 HA/IP failover solution for on-premises and bare-metal Kubernetes clusters.
Smarty
53
star
9

powerdns_exporter

📈 Prometheus metrics exporter for PowerDNS
Go
34
star
10

go-rancher-gen

🐮 Generate configuration files using templates and Rancher Metadata
Go
32
star
11

docker-calibre-web

🐳 Docker image for Calibre Web
Shell
32
star
12

terraform-rancheros-vmware

HCL
23
star
13

go-spinner

GO spinner / activity indicator for command line applications
Go
21
star
14

docker-nfs-ganesha

🐳 🚢 NFS-Ganesha Docker Image
Shell
16
star
15

docker-shipyard-armv7

🐳 Shipyard Docker management for Raspberry Pi 2 / Scaleway C1
JavaScript
11
star
16

docker-alpine-haproxy

🐳 Haproxy docker image based on Alpine Linux
Makefile
10
star
17

go-redwall

🔥 Dockerized distributed dynamic firewall daemon with Redis backend
Go
8
star
18

Docker-RemoteSyslog2

🐳 Forward server or container logs to remote syslog collectors
Shell
8
star
19

meta-k3s

Shell
7
star
20

stdemuxerhook

🔀 A hook for logrus logger that demuxes logs to stderr and stdout based on severity
Go
6
star
21

datadog-rancher-init

🐶 Sidekick container image for running Datadog Agent in Rancher environments
Python
6
star
22

rancher-v2-logging

6
star
23

habitat-plans

Shell
4
star
24

ansible-k3s-2-node-ha

Ansible playbook for setting up a 2-node, high available k3s cluster using an embedded replicated database
Shell
4
star
25

tiny-operators-catalog

Shell
3
star
26

meta-k3s-odroid-c2

Shell
2
star
27

go-ipintel

👮 Go wrapper for the getipintel.net proxy detection API
Go
2
star
28

fleet-demo

2
star
29

nginx-php55

🐳 Nginx/PHP5.5/NodeJS/Ruby Docker image based on CentOS 7
Shell
1
star
30

k8s-nginx-demo

1
star
31

docker-armhf

🐳 Docker in Docker for ARMv7!
Shell
1
star
32

dotfiles

Shell
1
star
33

docker-selfoss-nginx

🐳 Selfoss - http://selfoss.aditu.de Docker image
PHP
1
star
34

helm-charts

Public Helm chart repository
1
star
35

harvester-rke2-cluster-template

Example RKE2 cluster template for Harvester IaaS
1
star
36

k3s-fleet-demos

1
star
37

ndppd-alpine

Shell
1
star
38

blinken-k8s

Shell
1
star
39

docker-debian-nginx

🐳 Nginx 1.8 (Dotdeb) image based on Debian Wheezy
Shell
1
star
40

docker-debian-s6

🐳 Official debian images pimped with the s6 process supervisor
Shell
1
star
41

rancher-hello-world

Python
1
star