AlpineLinux How-To's
Alpine Linux, the lightweight distribution is often preferred for the base image of containers. Its package repository provides, most if not all applications relative to other distros such as Ubuntu or Fedora.
What follows is a collection of typical Linux tasks, needing to be performed in Alpine Linux context.
Alpine Linux Installation
The setup-alpine
command kickstarts the installation with interactive Q&A prompts, such as:
Initialize network interface and configure NTP
Set
root
user passwordCreate new user account
Install SSH server
Partition the disk (choose
sys
as type of partition)
setup-alpine
Package Repository Configuration
VERSION=$(cat /etc/*release* | grep -i version_id | awk -F'=' '{printf "v"$NF"\n"}' | sed -E 's/.0//g')
tee -a /etc/apk/repositories < END
/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/$VERSION/main
http://dl-cdn.alpinelinux.org/alpine/$VERSION/community
END
apk update
Docker Installation
apk update && \
apk add docker docker-cli-compose && \
/etc/init.d/docker start && \
rc-update add docker default
# add the non-privileged user to docker group
addgroup $USER docker
docker version
docker compose version
Note that docker-compose
equivalent in Alpine Linux is docker compose
.
New User Account
adduser -g "alpine" alpine #adduser -g "Full name" username
addgroup alpine wheel #addgroup username groupname
apk add doas
echo "permit persist :wheel" >> /etc/doas.d/doas.conf
SSH Installation
Set DHCP on the primary network interface
#cat /etc/network/interfaces auto eth0 iface eth0 inet dhcp
/etc/init.d/networking restart
Install OpenSSH-server package
apk add openssh-server && \ /etc/init.d/sshd start && \ rc-update add sshd