This guide instructs you on how to put Alpine Linux on a Digital Ocean (referral link) droplet.
- Digital Ocean account
- Local Docker installation (used to generate the Alpine root filesystem)
- Ensure Docker is running.
- Download and unzip
gliderlabs/docker-alpine.wget -O docker-alpine-master.zip https://github.com/gliderlabs/docker-alpine/archive/master.zipunzip docker-alpine-master.zip
- Build the builder.
docker build -t docker-alpine-builder docker-alpine-master/builder/
- Build the root file system (change
v3.3to the Alpine version you want to build).docker run --name alpine-builder docker-alpine-builder -r v3.3
- Copy the root file system from the container.
docker cp alpine-builder:/rootfs.tar.gz .
- (Optional) Clean up builder.
docker rm alpine-builderdocker rmi docker-alpine-builderrm -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".
- Fill in your information, select the "Debian 7.9 x64" image, and click "Create Droplet".
- Transfer
rootfs.tar.gzto 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 /alpinetar xf rootfs.tar.gz -C /alpinepoweroff
- In your Digital Ocean droplet control panel, click "Settings".
- Under the "Recovery" tab, click "Mount Recovery Kernel".
- Under "Power", click "Power On".
- Under "Access", click "Console Access".
- In the recovery console, move the extracted Alpine files into the root of your drive.
mkdir /mntmount -t ext4 /dev/vda1 /mntmv /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
- Click "Back to Droplet".
- Under "Settings", click "Kernel" tab.
- Select "Original Kernel", then click "Change".
- Under "Power", click "Power On".
- Re-open "Console Access".
- Login as
root. - Enable writing to the file system.
mount -o rw,remount /dev/vda1 /vi /etc/fstab- Set the 4th column to
defaults - Save and exit.
- Configure networking and SSH.
setup-hostnamesetup-dnsservice networking restartapk updatesetup-sshd
- Enable services.
rc-update add hostname bootrc-update add networking bootrc-update add urandom bootrc-update add cronrc-update add swap boot
- Reboot.
reboot
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.
Creative Commons Attribution 4.0 International License
Tim Cooper (tim.cooper@layeh.com)