Skip to content

Instantly share code, notes, and snippets.

@leiless
Last active July 11, 2024 10:35
Show Gist options
  • Save leiless/43233485a45c5bc0203292a1c3d00418 to your computer and use it in GitHub Desktop.
Save leiless/43233485a45c5bc0203292a1c3d00418 to your computer and use it in GitHub Desktop.
HOWTO install podman in Armbian Ubuntu
# 1. Install podman
# https://podman.io/getting-started/installation#ubuntu
. /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install podman
# 2. Install missing dependencies
sudo apt-get install -y uidmap fuse-overlayfs slirp4netns
# 3. Install cni-plugins
# https://github.com/containernetworking/plugins/releases
# Or sudo apt-get install -y containernetworking-plugins
sudo mkdir -p /usr/local/lib/cni
sudo tar xf cni-plugins-linux-arm64-v1.0.1.tgz -C /usr/local/lib/cni
ls -l /usr/local/lib/cni
# 4. Make an alias
sudo ln -s "$(which podman)" "$(dirname "$(which podman)")/docker"
@leiless
Copy link
Author

leiless commented Oct 12, 2021

$ podman run -it --rm hello-world
WARN[0000] Error validating CNI config file /home/lei/.config/cni/net.d/87-podman.conflist: [failed to find plugin "bridge" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "portmap" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "firewall" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "tuning" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin]] 
$ ls -l /usr/libexec/cni
total 7868
-rwxr-xr-x 1 root root 3197720 Mar 25  2021 dnsname
-rwxr-xr-x 1 root root 4857208 Jun 16 10:49 podman-machine

$ ls -l /usr/local/lib/cni
total 64720
-rwxr-xr-x 1 root root 3910093 Sep  7 19:49 bandwidth
-rwxr-xr-x 1 root root 4221528 Sep  7 19:49 bridge
-rwxr-xr-x 1 root root 9261910 Sep  7 19:49 dhcp
-rwxr-xr-x 1 root root 4329831 Sep  7 19:49 firewall
-rwxr-xr-x 1 root root 3926829 Sep  7 19:49 host-device
-rwxr-xr-x 1 root root 3370993 Sep  7 19:49 host-local
-rwxr-xr-x 1 root root 4025250 Sep  7 19:49 ipvlan
-rwxr-xr-x 1 root root 3386929 Sep  7 19:49 loopback
-rwxr-xr-x 1 root root 4109215 Sep  7 19:49 macvlan
-rwxr-xr-x 1 root root 3767425 Sep  7 19:49 portmap
-rwxr-xr-x 1 root root 4202554 Sep  7 19:49 ptp
-rwxr-xr-x 1 root root 3569021 Sep  7 19:49 sbr
-rwxr-xr-x 1 root root 2935983 Sep  7 19:49 static
-rwxr-xr-x 1 root root 3558286 Sep  7 19:49 tuning
-rwxr-xr-x 1 root root 4023421 Sep  7 19:49 vlan
-rwxr-xr-x 1 root root 3645410 Sep  7 19:49 vrf

References

https://podman.io/getting-started/installation#ubuntu
https://github.com/containernetworking/plugins/releases
https://medium.com/@liuyutong2921/network-failed-to-find-plugin-bridge-in-path-opt-cni-bin-70e7156ceb0b

@leiless
Copy link
Author

leiless commented Oct 12, 2021

image

@leiless
Copy link
Author

leiless commented Oct 16, 2021

$ sudo apt install -y podman
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  catatonit conmon containers-common criu crun dnsmasq-base iptables libgpgme11 libidn11 libip6tc2 libnet1
  libnetfilter-conntrack3 libnfnetlink0 libnftnl11 libprotobuf-c1 libprotobuf17 libyajl2 podman-machine-cni
  podman-plugins python3-protobuf
Suggested packages:
  firewalld nftables
Recommended packages:
  dns-root-data slirp4netns containernetworking-plugins uidmap fuse-overlayfs
The following NEW packages will be installed:
  catatonit conmon containers-common criu crun dnsmasq-base iptables libgpgme11 libidn11 libip6tc2 libnet1
  libnetfilter-conntrack3 libnfnetlink0 libnftnl11 libprotobuf-c1 libprotobuf17 libyajl2 podman podman-machine-cni
  podman-plugins python3-protobuf
0 upgraded, 21 newly installed, 0 to remove and 1 not upgraded.
Need to get 20.6 MB of archives.

Final solution:

sudo apt install -y podman dns-root-data slirp4netns containernetworking-plugins uidmap fuse-overlayfs

dns-root-data is optional, but recommended

@leiless
Copy link
Author

leiless commented Oct 16, 2021

armbian/build diff

git clone -b v21.08 --depth 1 https://github.com/armbian/build

./compile.sh docker BOARD=nanopi-r4s BRANCH=current RELEASE=focal BUILD_MINIMAL=yes BUILD_DESKTOP=no KERNEL_ONLY=no KERNEL_CONFIGURE=no COMPRESS_OUTPUTIMAGE=sha,img,xz DOWNLOAD_MIRROR=china MAINLINE_MIRROR=tuna EXTRAWIFI=no WIREGUARD=no AUFS=no
diff --git a/config/templates/Dockerfile b/config/templates/Dockerfile
index 666ac7e..ae81622 100644
--- a/config/templates/Dockerfile
+++ b/config/templates/Dockerfile
@@ -1,6 +1,7 @@
 FROM ubuntu:21.04
 ARG DEBIAN_FRONTEND=noninteractive
-RUN apt-get update && apt-get -y install \
+RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
+        apt-get update && apt-get -y install \
        joe \
        software-properties-common \
        gnupg \
diff --git a/config/templates/config-docker.conf b/config/templates/config-docker.conf
index 945b6de..a49ca9b 100644
--- a/config/templates/config-docker.conf
+++ b/config/templates/config-docker.conf
@@ -39,7 +39,8 @@ DOCKER_FLAGS+=(--cap-add=SYS_ADMIN --cap-add=MKNOD --cap-add=SYS_PTRACE)
 
 # mounting things inside the container on Ubuntu won't work without this
 # https://github.com/moby/moby/issues/16429#issuecomment-217126586
-DOCKER_FLAGS+=(--security-opt=apparmor:unconfined)
+#DOCKER_FLAGS+=(--security-opt=apparmor:unconfined)
+DOCKER_FLAGS+=(--security-opt label=disable)
 
 # remove resulting container after exit to minimize clutter
 # bad side effect - named volumes are considered not attached to anything and are removed on "docker volume prune"

@leiless
Copy link
Author

leiless commented May 19, 2022

Sometimes when you met the SHASUM hash mismatch, you would like to download the deb directly.

Get:20 https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04  podman 100:3.4.2-1 [17.7 MB]
Err:20 https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04  podman 100:3.4.2-1 
  File has unexpected size (17679080 != 17706544). Mirror sync in progress? [IP: 130.236.254.253 443]
  Hashes of expected file:
   - SHA256:4eb9b58413f602cf18ec21a742acd99ae10e71df467e7b9a63c3b1f7e8229f16
   - SHA1:cf1fefe5c85321fe9b562339a79494c9eda9dd60 [weak]
   - MD5Sum:58fa232055dff2700aa55e13c7932536 [weak]
   - Filesize:17706544 [weak]
...
E: Failed to fetch https://ftp.lysator.liu.se/pub/opensuse/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/amd64/podman_3.4.2-1_amd64.deb  File has unexpected size (17679080 != 17706544). Mirror sync in progress? [IP: 130.236.254.253 443]
   Hashes of expected file:
    - SHA256:4eb9b58413f602cf18ec21a742acd99ae10e71df467e7b9a63c3b1f7e8229f16
    - SHA1:cf1fefe5c85321fe9b562339a79494c9eda9dd60 [weak]
    - MD5Sum:58fa232055dff2700aa55e13c7932536 [weak]
    - Filesize:17706544 [weak]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Like:
https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/amd64/podman_3.4.2-1_amd64.deb.mirrorlist
Download from original source(not from the mirror): https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/amd64/podman_3.4.2-1_amd64.deb

curl -LO https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/amd64/podman_3.4.2-1_amd64.deb
sudo apt install -y ./podman_3.4.2-1_amd64.deb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment