A demo of a Go program running an Ubuntu linux container via containerd with bridged networking via CNI plugins
- Install Go 1.18+
- Git Clone
scripts/./install_cni.sh
scripts/./run.sh
You should see an output as follows:
2022/06/25 13:10:35 Writing network config...
2022/06/25 13:10:35 CNI initialized
2022/06/25 13:10:36 images found: 1
2022/06/25 13:10:36 Image docker.io/library/ubuntu:latest
2022/06/25 13:10:36 ubuntu-server2 has IP: 10.62.0.34.
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [109 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [17.5 MB]
Get:6 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [212 kB]
Get:7 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [94.9 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [238 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [4648 B]
Get:10 http://archive.ubuntu.com/ubuntu jammy/restricted amd64 Packages [164 kB]
Get:11 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [266 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages [1792 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [162 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [4648 B]
Get:15 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [406 kB]
Get:16 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [250 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [5157 B]
Fetched 21.7 MB in 2s (10.3 MB/s)
Reading package lists...
Building dependency tree...
Reading state information...
8 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages will be upgraded:
e2fsprogs libcom-err2 libext2fs2 libss2 libssl3 libsystemd0 libudev1 logsave
8 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 3125 kB of archives.
After this operation, 2048 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libsystemd0 amd64 249.11-0ubuntu3.3 [318 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 logsave amd64 1.46.5-2ubuntu1.1 [9932 B]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libext2fs2 amd64 1.46.5-2ubuntu1.1 [208 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 e2fsprogs amd64 1.46.5-2ubuntu1.1 [591 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcom-err2 amd64 1.46.5-2ubuntu1.1 [9158 B]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libssl3 amd64 3.0.2-0ubuntu1.5 [1900 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libudev1 amd64 249.11-0ubuntu3.3 [77.4 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libss2 amd64 1.46.5-2ubuntu1.1 [12.3 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 3125 kB in 1s (3261 kB/s)
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../libsystemd0_249.11-0ubuntu3.3_amd64.deb ...
Unpacking libsystemd0:amd64 (249.11-0ubuntu3.3) over (249.11-0ubuntu3.1) ...
Setting up libsystemd0:amd64 (249.11-0ubuntu3.3) ...
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../logsave_1.46.5-2ubuntu1.1_amd64.deb ...
Unpacking logsave (1.46.5-2ubuntu1.1) over (1.46.5-2ubuntu1) ...
Preparing to unpack .../libext2fs2_1.46.5-2ubuntu1.1_amd64.deb ...
Unpacking libext2fs2:amd64 (1.46.5-2ubuntu1.1) over (1.46.5-2ubuntu1) ...
Setting up libext2fs2:amd64 (1.46.5-2ubuntu1.1) ...
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../e2fsprogs_1.46.5-2ubuntu1.1_amd64.deb ...
Unpacking e2fsprogs (1.46.5-2ubuntu1.1) over (1.46.5-2ubuntu1) ...
Preparing to unpack .../libcom-err2_1.46.5-2ubuntu1.1_amd64.deb ...
Unpacking libcom-err2:amd64 (1.46.5-2ubuntu1.1) over (1.46.5-2ubuntu1) ...
Setting up libcom-err2:amd64 (1.46.5-2ubuntu1.1) ...
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../libssl3_3.0.2-0ubuntu1.5_amd64.deb ...
Unpacking libssl3:amd64 (3.0.2-0ubuntu1.5) over (3.0.2-0ubuntu1.2) ...
Setting up libssl3:amd64 (3.0.2-0ubuntu1.5) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: falling back to frontend: Teletype
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../libudev1_249.11-0ubuntu3.3_amd64.deb ...
Unpacking libudev1:amd64 (249.11-0ubuntu3.3) over (249.11-0ubuntu3.1) ...
Setting up libudev1:amd64 (249.11-0ubuntu3.3) ...
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../libss2_1.46.5-2ubuntu1.1_amd64.deb ...
Unpacking libss2:amd64 (1.46.5-2ubuntu1.1) over (1.46.5-2ubuntu1) ...
Setting up libss2:amd64 (1.46.5-2ubuntu1.1) ...
Setting up logsave (1.46.5-2ubuntu1.1) ...
Setting up e2fsprogs (1.46.5-2ubuntu1.1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libcap2-bin libpam-cap
The following NEW packages will be installed:
iputils-ping libcap2-bin libpam-cap
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 76.8 kB of archives.
After this operation, 280 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libcap2-bin amd64 1:2.44-1build3 [26.0 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 iputils-ping amd64 3:20211215-1 [42.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libpam-cap amd64 1:2.44-1build3 [7932 B]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 76.8 kB in 1s (82.0 kB/s)
Selecting previously unselected package libcap2-bin.
(Reading database ... 4395 files and directories currently installed.)
Preparing to unpack .../libcap2-bin_1%3a2.44-1build3_amd64.deb ...
Unpacking libcap2-bin (1:2.44-1build3) ...
Selecting previously unselected package iputils-ping.
Preparing to unpack .../iputils-ping_3%3a20211215-1_amd64.deb ...
Unpacking iputils-ping (3:20211215-1) ...
Selecting previously unselected package libpam-cap:amd64.
Preparing to unpack .../libpam-cap_1%3a2.44-1build3_amd64.deb ...
Unpacking libpam-cap:amd64 (1:2.44-1build3) ...
Setting up libcap2-bin (1:2.44-1build3) ...
Setting up libpam-cap:amd64 (1:2.44-1build3) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
Setting up iputils-ping (3:20211215-1) ...
PING google.com (172.217.30.206) 56(84) bytes of data.
64 bytes from (172.217.30.206): icmp_seq=1 ttl=115 time=10.2 ms
64 bytes from (172.217.30.206): icmp_seq=2 ttl=115 time=10.5 ms
64 bytes from (172.217.30.206): icmp_seq=3 ttl=115 time=10.4 ms
64 bytes from (172.217.30.206): icmp_seq=4 ttl=115 time=10.4 ms
64 bytes from (172.217.30.206): icmp_seq=5 ttl=115 time=10.4 ms
--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4005ms
rtt min/avg/max/mdev = 10.213/10.368/10.485/0.089 ms
container finishing
container exited with status: 0