Alpine Linux
Getting started with Alpine Linux on VPS, apk package manager, OpenRC services, networking and key differences from Ubuntu/Debian
Alpine is a minimal distribution (< 10MB base) built on musl libc and BusyBox. Widely used for Docker containers, but also excellent for VPS when you need a small footprint. Key differences: uses apk instead of apt, OpenRC instead of systemd, musl libc instead of glibc, and BusyBox utilities instead of GNU coreutils.
First Steps After Login
Update the package index:
apk updateUpgrade all packages:
apk upgradeInstall essential tools:
apk add bash curl wget nano vim git htopInstall sudo:
apk add sudoAdd your user to the wheel group (for sudo access):
addgroup username wheelAPK Package Manager
Alpine's package manager is apk. Main commands:
apk update # update package index
apk upgrade # upgrade all packages
apk add package # install package
apk del package # remove package
apk search keyword # search packages
apk info package # package information
apk info -L package # list files in package
apk list --installed # show installed packagesRepositories
Edit /etc/apk/repositories to enable additional repos (main, community, edge):
cat /etc/apk/repositoriesMain repos: main (stable), community (community-maintained), edge (latest development).
OpenRC Service Management
Alpine uses OpenRC, not systemd. Equivalences:
| systemd | OpenRC |
|---|---|
systemctl start nginx | rc-service nginx start |
systemctl stop nginx | rc-service nginx stop |
systemctl restart nginx | rc-service nginx restart |
systemctl status nginx | rc-service nginx status |
systemctl enable nginx | rc-update add nginx default |
systemctl disable nginx | rc-update del nginx |
systemctl list-units | rc-status |
View all services:
rc-statusNetwork Configuration
Alpine uses /etc/network/interfaces (busybox ifupdown). No netplan or NetworkManager by default.
Static IPv4
Edit /etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1Apply changes:
rc-service networking restartDHCP
For DHCP configuration:
auto eth0
iface eth0 inet dhcpDNS
Edit /etc/resolv.conf:
nameserver 1.1.1.1
nameserver 8.8.8.8IPv6 on Alpine
IPv6 requires explicit configuration on Alpine. It does not activate automatically like on Ubuntu.
Step 1: Enable IPv6 in Kernel
Check if IPv6 is disabled:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6Enable temporarily:
echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6Make permanent in /etc/sysctl.conf:
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0Apply:
sysctl -pStep 2: Configure IPv6 Static Address
Edit /etc/network/interfaces:
auto eth0
iface eth0 inet6 static
address 2001:db8::1
netmask 64
gateway 2001:db8::1
pre-up echo 0 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6For SLAAC/DHCP IPv6 (if provider supports RA):
iface eth0 inet6 auto
pre-up echo 1 > /proc/sys/net/ipv6/conf/eth8/accept_raRestart networking:
rc-service networking restartTest IPv6
ping6 ipv6.google.com
ip -6 addr showIf the IPv6 address does not appear after restart, verify that your hosting provider has assigned an IPv6 block to your VPS in the control panel (DeluxHost → Network).
Installing Common Software
Nginx Web Server
apk add nginx
rc-update add nginx default
rc-service nginx startDocker
apk add docker docker-compose
rc-update add docker default
rc-service docker startSSH Server
SSH is usually pre-installed:
apk add openssh
rc-update add sshd default
rc-service sshd startCommon Gotchas
musl libc vs glibc
Some binaries compiled for glibc don't run on Alpine. Use Alpine packages from apk or compile from source.
BusyBox Utilities
Some command flags differ from GNU versions. Install GNU tools for compatibility:
apk add coreutils grep sedNo systemd
Scripts using systemctl must be adapted for OpenRC.
Shell Differences
/bin/sh is BusyBox ash, not bash. For bash scripts, use #!/bin/bash header and install bash:
apk add bashAlpine is ideal for Docker containers or VPS with limited resources. For servers with many packages installed, Ubuntu/Debian are often more convenient due to better software compatibility.