Getting Started

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 update

Upgrade all packages:

apk upgrade

Install essential tools:

apk add bash curl wget nano vim git htop

Install sudo:

apk add sudo

Add your user to the wheel group (for sudo access):

addgroup username wheel

APK 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 packages

Repositories

Edit /etc/apk/repositories to enable additional repos (main, community, edge):

cat /etc/apk/repositories

Main repos: main (stable), community (community-maintained), edge (latest development).


OpenRC Service Management

Alpine uses OpenRC, not systemd. Equivalences:

systemdOpenRC
systemctl start nginxrc-service nginx start
systemctl stop nginxrc-service nginx stop
systemctl restart nginxrc-service nginx restart
systemctl status nginxrc-service nginx status
systemctl enable nginxrc-update add nginx default
systemctl disable nginxrc-update del nginx
systemctl list-unitsrc-status

View all services:

rc-status

Network 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.1

Apply changes:

rc-service networking restart

DHCP

For DHCP configuration:

auto eth0
iface eth0 inet dhcp

DNS

Edit /etc/resolv.conf:

nameserver 1.1.1.1
nameserver 8.8.8.8

IPv6 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_ipv6

Enable temporarily:

echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 0 > /proc/sys/net/ipv6/conf/default/disable_ipv6

Make permanent in /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0

Apply:

sysctl -p

Step 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_ipv6

For SLAAC/DHCP IPv6 (if provider supports RA):

iface eth0 inet6 auto
    pre-up echo 1 > /proc/sys/net/ipv6/conf/eth8/accept_ra

Restart networking:

rc-service networking restart

Test IPv6

ping6 ipv6.google.com
ip -6 addr show

If 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 start

Docker

apk add docker docker-compose
rc-update add docker default
rc-service docker start

SSH Server

SSH is usually pre-installed:

apk add openssh
rc-update add sshd default
rc-service sshd start

Common 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 sed

No 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 bash

Alpine 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.

On this page