Alpine Linux Guide
Alpine Linux is a security-oriented, lightweight Linux distribution based on musl libc and BusyBox. It's the go-to choice for Docker containers due to its minimal footprint.
Dai Aoki
CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm
Overview
Alpine Linux was created in 2005 from the LEAF Project. Its minimal design makes it extremely popular for containerized applications, where image size and security matter.
Quick Facts
| Based On | Independent (musl/BusyBox) |
| Package Manager | apk (Alpine Package Keeper) |
| Default Desktop | None (server-focused) |
| Release Cycle | Every 6 months |
| Support Period | 2 years per release |
| Init System | OpenRC |
Who Should Use Alpine?
- Container developers - Minimal images for Docker/Kubernetes
- Embedded systems - Small footprint for IoT devices
- Security-conscious users - Hardened by default
- Minimalists - Build exactly what you need
- Network appliances - Routers, firewalls, VPNs
Installation
Alpine uses a script-based installer:
- Download the ISO from alpinelinux.org
- Boot from the ISO (CD/USB)
- Login as root (no password)
- Run setup-alpine to start installation
- Answer configuration questions
# Start Alpine installation
setup-alpine
# The script will ask about:
# - Keyboard layout
# - Hostname
# - Network configuration
# - Root password
# - Timezone
# - Mirror selection
# - Disk setup (sys, data, or diskless)
# For disk installation, choose 'sys' modePackage Management
Alpine uses apk, a fast and simple package manager:
# Update package index
apk update
# Upgrade all packages
apk upgrade
# Install a package
apk add package-name
# Remove a package
apk del package-name
# Search for packages
apk search keyword
# Show package info
apk info package-name
# List installed packages
apk list --installed
# Add from testing repository
apk add package-name --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testingKey Features
musl libc
Alpine uses musl instead of glibc. It's smaller and more secure, but some glibc-specific software may require compatibility layers.
BusyBox
Single binary providing most Unix utilities. Reduces system size while maintaining functionality.
PaX/grsecurity
Hardened kernel with enhanced security features to prevent exploits.
OpenRC
Lightweight init system instead of systemd. Simple and fast boot process.
Alpine in Docker
Alpine is the most popular base image for Docker containers:
# Simple Alpine Dockerfile example
FROM alpine:3.19
# Install packages
RUN apk add --no-cache \
python3 \
py3-pip
# Set working directory
WORKDIR /app
# Copy application
COPY . .
# Run application
CMD ["python3", "app.py"]Alpine Docker Image Sizes
| alpine | ~5MB |
| alpine + Python | ~50MB |
| alpine + Node.js | ~60MB |
| Compare: debian-slim | ~70MB (base only) |
FAQ
Why doesn't my glibc application work?
Alpine uses musl, not glibc. Install gcompatfor compatibility, or use a glibc-based image for applications that require it.
Is Alpine suitable for desktops?
Alpine can run desktop environments, but it's not its primary use case. Some applications may have compatibility issues with musl.
How do I install bash on Alpine?
Alpine uses ash (from BusyBox) by default. Install bash withapk add bash if needed.
Summary
Alpine Linux excels in containerized environments where size and security matter. Key takeaways:
- Extremely lightweight (~5MB base image)
- musl libc for security and size benefits
- apk package manager is fast and simple
- Ideal for Docker and Kubernetes
- Hardened kernel with PaX/grsecurity
Official Documentation
For authoritative information, refer to the official documentation: