Alpine Linux as a ESXi Docker host

Once again realized that Rancher OS is not supported anymore

After quick "googling" it seems that there is no so much alternatives right now

Photon OS from VMWare is almost same as Ubuntu and from previous experiments I'm already able to have really small footprint docker host but wondering how much further can it go

Alpine Images

Alpine images can be downloaded here

One we are looking for is under "Virtual"

https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-virt-3.15.0-x86_64.iso

ISO size is only 55mb in size which is really promising

Unfortunatelly there is no something like cloud ready vmdk with build in cloud init at moment, but there are already AWS ready images, so hopefully it will be available in future, so unfortunately setup is manual, but because of how simple and small Alpine is it wont take more than few minutes

ESXi

From ESXi perspective nothing fancy, we are going to create simple virtual machine as usual, as a guest system "Other 5.x or later Linux (64-bit)"

Other Linux 64 bit Guest OS

Also make sure that BIOS is used to boot

BIOS boot options

If everything fine, after power on you will be almost immediatelly boot and promted to login (still can not belive how fast it is)

Default username is "root" with empty password

Alpine Setup

From a welcome message you cann see that you may use setup-alpine script to actually install OS

So I give it a go and run setup-alping, and here are answers:

  • Select keyboard layout: none
  • Enter system hostname: demo.mac-blog.org.ua
  • Which one do you want ot initialize?: eth0
  • Ip address for eth0: 192.168.106.23
  • Netmask: 255.255.255.0
  • Gateway: 192.168.106.1
  • Do you want to do any manual network configuration: n
  • DNS domain name: empty string
  • DNS nameservers: 1.1.1.1,8.8.8.8
  • New password: HelloWorld
  • Retryp password: HelloWorld
  • Which timezone are you in: Europe/Kiev
  • HTTP proxy URL: none
  • Which NTP client to run: chrony
  • Enter mirror number: 1
  • Which SSH server: openssh
  • Which disk(s) would you like to use: sda
  • How wold you like to use it: sys
  • WARNING: Erase the above disk(s) and continue: y

Actually it is so straight forward that even does not require any notes

After setup which happens really really fast, Alpine will ask you to reboot, so run reboot and you are done

After booting up, it is good time to install open vm tools

To do this uncomment community link at /etc/apk/repositories so it looks like:

#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.15/main
http://dl-cdn.alpinelinux.org/alpine/v3.15/community
#http://dl-cdn.alpinelinux.org/alpine/edge/main
#http://dl-cdn.alpinelinux.org/alpine/edge/community
#http://dl-cdn.alpinelinux.org/alpine/edge/testing

Then open vm tools can be installed

apk add --update open-vm-tools
/etc/init.d/open-vm-tools start
rc-update add open-vm-tools

After this ESXi should recognize vm tools are installed

vmtools

But still wont show ip addresses

Install Alpine on VMware ESXi - wiki page I started from

Alpine SSH

After fresh install for remote connections to work make sure to tune /etc/ssh/sshd_config:

PermitRootLogin yes
PasswordAuthentication yes

And restart ssh by running /etc/init.d/sshd restart

Setting up a SSH server

Docker

Once again make sure that community packages are uncommented in /etc/apk/repositories

apk add docker
rc-update add docker boot
service docker start

Optionally apk add docker-compose (is not needed, in fresh releases docker compose v2 is single binary - docs)

Docker

Resize disk

apk add cfdisk

Choose desired disk, resize, and press enter

cfdisk

After that green line with free space should dissapear

Write changes and quit

Now we need to resize filesystem

apk add e2fsprogs-extra
resize2fs /dev/sda3

Make sure to change sda3 to appropriate number

And check what you have now

df -h /dev/sda3

Expanding Disk in Alpine Linux

Alpine install on a single partition without swap

apk add e2fsprogs
mkfs.ext4 -O ^has_journal /dev/sdXY   # the "-O ^has_journal" DISABLES journaling ("^" means "not")
mount /dev/sda1 /mnt
setup-disk /mnt

TODO: wish to have single partition without swap

Upgrading Alpine

apk update
apk upgrade

Tutorials and Howtos