This guide instructs you on how to put Alpine Linux on a Digital Ocean (referral link for $10) droplet.
- Digital Ocean account
- Local Docker installation (used to generate the Alpine root filesystem)
- Ensure Docker is running locally.
- Download and unzip
gliderlabs/docker-alpine
.wget -O docker-alpine-master.zip https://github.com/gliderlabs/docker-alpine/archive/master.zip
unzip docker-alpine-master.zip
- Build the builder.
docker build -t docker-alpine-builder docker-alpine-master/builder/
- Build the root file system (change
v3.3
to the Alpine version you want to build).docker run --name alpine-builder docker-alpine-builder -r v3.4
- Copy the root file system from the container.
docker cp alpine-builder:/rootfs.tar.gz .
- (Optional) Clean up builder.
docker rm alpine-builder
docker rmi docker-alpine-builder
rm -rf docker-alpine-master{,.zip}
You should now have rootfs.tar.gz
in your current directory.
- Create droplet.
- In your Digital Ocean control panel, click "Create Droplet".
- Select the "Debian 7.11 x64" image, fill in the rest of your information, and click "Create Droplet".
- Transfer
rootfs.tar.gz
to the droplet.scp rootfs.tar.gz root@<IP address>:
- SSH into the droplet.
ssh root@<IP address>
- Inside the droplet, extract the Alpine files onto your hard drive.
mkdir /alpine
tar xf rootfs.tar.gz -C /alpine
poweroff
- In your Digital Ocean droplet control panel, click "Kernel".
- Click "Mount Recovery Kernel".
- Switch on your droplet.
- Click "Console".
- In the recovery console, move the extracted Alpine files into the root of your drive.
mkdir /mnt
mount -t ext4 /dev/vda1 /mnt
mv /mnt/etc/network/interfaces /mnt/alpine/etc/network/
mv /mnt/root/.ssh/ /mnt/alpine/root/
mv /mnt/etc/fstab /mnt/alpine/etc/
mv /mnt/alpine/ /tmp/
rm -rf /mnt/*
mv /tmp/alpine/* /mnt/
umount /mnt/
poweroff
- Close the recovery console.
- Select a kernel (e.g. search for "3.2.0-4-amd64"), then click "Change".
- Switch on your droplet.
- Click "Console" in your droplet control panel.
- Login as
root
. - Enable writing to the file system.
mount -o rw,remount /dev/vda1 /
vi /etc/fstab
- Set the 4th column (options) of the
/
mount point todefaults
- Save and exit.
- Configure networking and SSH.
setup-hostname
setup-dns
service networking restart
apk update
setup-sshd
- Enable services.
rc-update add hostname boot
rc-update add networking boot
rc-update add urandom boot
rc-update add crond
rc-update add swap boot
- Reboot.
reboot
- Close the console.
After removing the old SSH fingerprint from your local machine's ~/.ssh/known_hosts
file, you should now be able to SSH into your droplet.
- If you need a modules to work:
wget http://ftp.de.debian.org/debian/pool/main/l/linux/linux-image-3.16.0-4-amd64_3.16.7-ckt25-2_amd64.deb
apk add dpkg
apk add tar
dpkg-deb -x linux-image-3.16.0-4-amd64_3.16.7-ckt25-2_amd64.deb /tmp/out/
mv /tmp/out/lib/modules/ /lib/
depmod -a
rm linux-image-3.16.0-4-amd64_3.16.7-ckt25-2_amd64.deb
rm /tmp/out/ -fr
Creative Commons Attribution 4.0 International License
Tim Cooper ([email protected])