User talk:Docker

From postmarketOS
Jump to navigation Jump to search

My Raspberry Pi 3 died. It was used for running Plex server. It was running inside docker before the Pi died. I was looking for replacement. I looked into my basement and I found two Google_Nexus_5_(lg-hammerhead) phones. Then the story began...

Prerequisites

  • you are fairly familiar with how flashing works, e.g. fastboot stuff.
  • you've already running postmarketos on your phone
  • you know what docker is
  • you know that you are probably gonna remove all the fancy UIs from your phone, and switch to postmarketos-ui-fbkeyboard or some console only mode
  • you'd better have a LAN connection on your phone rather than wifi

Steps

I can only prove this is working on my phones for now.

K3s cluster built with hammerhead and docker.jpg


1. edit kernel config

NOTE: before you make any change to kernel, always backup ~/.local/var/pmbootstrap/cache_git/pmaports/main/linux-postmarketos-qcom-msm8974/config-postmarketos-qcom-msm8974.armv7

Run

pmbootstrap kconfig edit postmarketos-qcom-msm8974

where qcom-msm8974 is for my Nexus 5. You need to figure out what's for your phone.

You have 2 options to configure the kernel:

a) follow https://wiki.gentoo.org/wiki/Docker#Kernel (which doesn't really apply to kernel 5.9 but I made it)

b) run https://raw.githubusercontent.com/moby/moby/master/contrib/check-config.sh

You can see the changes I made to my kernel config at https://gitlab.com/tigerinus/pmaports/-/commit/d4c1ad862f5485fd9a7577e59b95e97da1b988ae

BTW - I've got a Ugreen USB 2.0 network adapter hooked, so I took the chance and selected Device Drivers => Network device support => <*> USB Network Adapters => <*> ASIX AX88xxx Based USB 2.0 Ethernet Adapters (or whatever adapter you have)

2. build the kernel

pmbootstrap build linux-postmarketos-qcom-msm8974 --force

I had to add --force otherwise it won't build.

If everything is successful, you should find something like below

~/.local/var/pmbootstrap/packages/edge/armv7/linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk

3. install the kernel

Get the linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk copied onto your phone and do

sudo apk add -u linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk

Just in case, I also copied /boot/boot.img-postmarketos-qcom-msm8974 to local as boot.img, boot to bootloader and did

fastboot flash boot boot.img

Reboot the phone and run check-config.sh again to see if anything missing. My experience is you don't need everything enabled.

Check-config.png

4. install docker

Boot to your phone, assuming you have a pretty good internet connection, then do

sudo apk add docker

Not only this installs docker, but also an important service containerd.

5. get docker daemon running

Run

sudo service docker start

We are not there yet. This first-time boot is for creating files, directories, group it needs. The docker command won't work because of couple things that have to happen at boot time below.


BTW - If you hate doing sudo docker... everytime, you can optionally add yourself to docker group by

sudo vi /etc/group

Now reboot so at least containerd service is effective, in terms of automatically mounting cgroup2 to /sys/fs/cgroup.

sudo reboot

After reboot, do

sudo service docker start

You should see something like

Sudo service docker start.png

which you won't see if you tried to start docker service before the reboot.

To start docker on boot, do

sudo rc-update add docker default

6. verify things are good

First thing first, health check

docker info

Docker info.png

Then

docker run --rm hello-world

Docker run hello world.png

Let's try get Fedora running on this little device

Docker run fedora.png


What's next?

kubernetes (k3s or microk8s)...

References

- https://wiki.alpinelinux.org/wiki/Docker

- https://wiki.gentoo.org/wiki/Docker#Kernel

- https://blog.hypriot.com/post/verify-kernel-container-compatibility/