summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2024-10-29 15:19:54 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2024-11-15 19:50:00 +0000
commiteb5c2bc4a5b48adf11a8fb3ae5cf63e65bde2f4a (patch)
treecb15787888d7c181e83bf55b56028edbdfff7e6a
parent1a87aca209b614d865246acb7701175e19866b5a (diff)
downloadmeta-virtualization-eb5c2bc4a5b48adf11a8fb3ae5cf63e65bde2f4a.tar.gz
documentation: add README.md for available container image types
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--recipes-extended/images/README.md287
1 files changed, 287 insertions, 0 deletions
diff --git a/recipes-extended/images/README.md b/recipes-extended/images/README.md
new file mode 100644
index 00000000..f087076a
--- /dev/null
+++ b/recipes-extended/images/README.md
@@ -0,0 +1,287 @@
1This README describes the contents of the reference images in
2this directory, as well as some testing and usability tips.
3
4container-image-host
5--------------------
6
7As described in the recipe, this is a flexible image definition that
8is suitable for building a container host image for a target.
9
10The configuration options for the image are best found in the recipe
11itself, so the information will not be duplicated here. The type of
12container host that will be created is controlled by the CONTAINER_PROFILE
13variable:
14
15i.e. in your local.conf: CONTAINER_PROFILE="docker"
16
17The valid settings for this variable can be found in the image recipe.
18
19The recipe checks for mandatory distro features, recommends others
20and provides a list of optional distro features for some workloads.
21
22This image also builds using virt-unique-hostname, which ensures that
23there is some randomization as hostname is often used to identify
24hosts when clustered (i.e. k3s).
25
26To have enough disk space for container images, it is configured
27with extra space. Depending on your use case, you can add (or remove)
28space as appropriate.
29
30Also note that more memory than the default is often required.
31
32An example execution of the image is:
33
34 % runqemu qemuarm64 nographic slirp qemuparams="-m 2048" tmp/deploy/images/qemuarm64/container-image-host-qemuarm64.rootfs.ext4
35
36ssh is enabled in this image by default, so the image can be accessed
37via:
38
39 % ssh -p 2222 root@127.0.0.1
40
41After a container image has been built, it can be copied fro the
42deploy directory to the registry of your choice, for example:
43
44 % cd build/tmp/deploy/images/qemuarm64
45 % skopeo copy --dest-creds <username>:<creds> oci:c3-systemd-container-latest-oci:latest docker://zeddii/c3-systemd-container
46
47Examples of pulling images to the container host for the various
48runtimes follow:
49
50 % podman pull --creds <username>:<password> zeddii/container-devtools
51 % podman run -it docker.io/zeddii/container-devtools bash
52
53 % root@qemuarm64-54:~# docker login
54 # Login Succeeded
55 % root@qemuarm64-54:~# docker pull zeddii/container-devtools
56
57 % root@qemuarm64-54:~# docker run -it --entrypoint /bin/sh zeddii/container-base
58 # [ 804.133881] docker0: port 1(veth2801d6a) entered blocking state
59 # [ 804.134425] docker0: port 1(veth2801d6a) entered disabled state
60 # [ 804.135018] veth2801d6a: entered allmulticast mode
61 # [ 804.136101] veth2801d6a: entered promiscuous mode
62 # [ 806.227282] eth0: renamed from veth384b37d
63 # [ 806.235331] docker0: port 1(veth2801d6a) entered blocking state
64 # [ 806.236010] docker0: port 1(veth2801d6a) entered forwarding state
65 # / # ls
66 # bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
67
68container-base:
69---------------
70
71Provides a minimal container image (but not absolutely smallest) that is
72inherited / included by the other container images.
73
74By default container base does not execute anything (it doesn't define
75and OCI_IMAGE_ENTRYPOINT), but does provide a shell that can be used
76to inspect the image.
77
78 % root@qemuarm64-54:~# docker run -it zeddii/container-base sh
79 [51393.764879] docker0: port 1(veth06cb397) entered blocking state
80 [51393.765340] docker0: port 1(veth06cb397) entered disabled state
81 [51393.765854] veth06cb397: entered allmulticast mode
82 [51393.766753] veth06cb397: entered promiscuous mode
83 [51396.060958] eth0: renamed from veth7e5a654
84 [51396.074281] docker0: port 1(veth06cb397) entered blocking state
85 [51396.074786] docker0: port 1(veth06cb397) entered forwarding state
86 / # ls
87 bin boot dev etc home lib media mnt proc run sbin sys tmp usr var
88 / # df -kh .
89 Filesystem Size Used Available Use% Mounted on
90 overlay 37.8G 1.9G 33.8G 5% /
91 / # du -sh .
92 2.6M .
93 / #
94
95 % root@qemuarm64-54:~# ctr images pull --user <user>:<password> docker.io/zeddii/container-base:latest
96 docker.io/zeddii/container base:latest saved
97 └──manifest (45395e734a93) complete |++++++++++++++++++++++++++++++++++++++|
98 ├──layer (1fd5069cdbad) waiting |--------------------------------------|
99 └──config (24b67db5b19e) waiting |--------------------------------------|
100 application/vnd.oci.image.manifest.v1+json sha256:45395e734a931468f5329d20d20babf13fbabbcd993e27b0e5c4198d09130966
101 Pulling from OCI Registry (docker.io/zeddii/container-base:latest) elapsed: 3.7 s total: 463.0 (123.0 B/s)
102
103 % root@qemuarm64-54:~# ctr run --rm -t docker.io/zeddii/container-base:latest zedd_shell sh
104 / # date
105 Tue Oct 29 00:09:19 UTC 2024
106 / #
107
108 % root@qemuarm64-54:~# nerdctl pull docker.io/zeddii/container-base:latest
109 docker.io/zeddii/container-base:latest: resolved |++++++++++++++++++++++++++++++++++++++|
110 docker.io/zeddii/container-base:latest: resolved |++++++++++++++++++++++++++++++++++++++|
111 manifest-sha256:45395e734a931468f5329d20d20babf13fbabbcd993e27b0e5c4198d09130966: exists |++++++++++++++++++++++++++++++++++++++|
112 config-sha256:24b67db5b19e0bb90291f1d5619362c7eaade7a8c65da9a32c2016394a5b57bf: exists |++++++++++++++++++++++++++++++++++++++|
113 elapsed: 1.2 s total: 0.0 B (0.0 B/s)
114
115 # FIXME: At the time of creating this README, bridge networking and CNI is not working.
116 % root@qemuarm64-54:~# nerdctl run -it --net=host docker.io/zeddii/container-base:latest sh
117 / #
118
119container-devtools-base:
120-------------------------
121
122includes container-base, and adds image features to make development
123tools/headers available.
124
125Anything added to CORE_DEV_IMAGE_EXTRA_INSTALL will be installed into
126the image in it's development variant.
127
128The container shell is changed to bash from busybox.
129
130package-management is added to this image type, but by default there
131is no package feed configured (since it must be pointed at a build)
132
133 % root@qemuarm64-54:~# docker run -it zeddii/container-devtools bash
134 bash-5.2# du -sh .
135 399M .
136 bash-5.2# rpm -qa | wc -l
137 308
138 bash-5.2# gcc --version
139 gcc (GCC) 14.2.0
140 Copyright (C) 2024 Free Software Foundation, Inc.
141 This is free software; see the source for copying conditions. There is NO
142 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
143
144container-app-base:
145--------------------
146
147Includes container-base.
148
149Provides an application container that installs a package (or packages) to
150the container and make the specified command the OCI_IMAGE_ENTRYPOINT.
151
152 CONTAINER_APP_CMD : the binary to run via the OCI_IMAGE_ENTRYPOINT
153 CONATINER_APP: packages to install to the container
154
155The default entry point is the "date" command.
156
157 % root@qemuarm64-54:~# docker run zeddii/container-app-base
158 Mon Oct 28 18:41:23 UTC 2024
159
160 % root@qemuarm64-54:~# docker run --entrypoint "du" zeddii/container-app-base -sh
161 2.6M .
162
163 % podman run docker.io/zeddii/container-app-base
164 Mon Oct 28 18:41:23 UTC 2024
165
166container-systemd-base:
167------------------------
168
169Extends container-base to create a systemd enabled container that is
170an appropriate starting point if a systemd applciation is being run
171or a mulit-user style environment is required.
172
173The application specified in SYSTEMD_CONTAINER_APP will be installed
174and be available to be executed.
175
176The rootfs of this container type is post processed to enable and
177disable services as specified by the containeer definition. This allows
178service that are not appropriate in a containerized environemnt to
179be disabled (i.e. getty login)
180
181The list of services can be found in the recipes themselves.
182
183This container enables ssh by default, so that it can be executed
184in the background and then accessed as a full environment.
185
186Note: this is currently a priviledged container if run under docker.
187
188There are multiple ways to add/remove permissions from the container,
189and most are configurable during launch:
190
191 % root@qemuarm64-54:~# docker run -d --rm --name systemd_test --privileged --cap-add SYS_ADMIN \
192 --security-opt seccomp=unconfined --cgroup-parent=docker.slice --cgroupns private \
193 --tmpfs /tmp --tmpfs /run --tmpfs /run/lock zeddii/systemd-container-base
194
195or
196
197 % docker run -d --rm --name systemd_test --privileged --cgroup-parent=docker.slice \
198 --cgroupns private zeddii/c3-systemd-container
199
200 % root@qemuarm64-54:~# docker ps
201 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
202 4b07cc907e26 zeddii/c3-systemd-container "/sbin/init" 5 minutes ago Up 5 minutes systemd_test
203
204 % podman run -d --name systemd_test --privileged --cgroupns=host --tmpfs /tmp --tmpfs /run --tmpfs /run/lock \
205 -v /sys/fs/cgroup:/sys/fs/cgroup:ro zeddii/systemd-container-base
206
207 % ctr container create --privileged --runtime="io.containerd.runc.v2" \
208 --mount type=bind,src=/sys/fs/cgroup,dst=/sys/fs/cgroup,options=rbind:rw \
209 docker.io/zeddii/systemd-container-base:latest my_systemd_container /sbin/init
210
211 % ctr task start --detach my_systemd_container
212
213 % ctr task ls
214 TASK PID STATUS
215 my_systemd_container 690 RUNNING
216
217Then add a user to the container so you can login:
218
219 % root@qemuarm64-54:~# docker exec systemd_test useradd testuser
220 % root@qemuarm64-54:~# docker exec systemd_test sh -c "echo 'testuser:password' | chpasswd"
221
222 % podman exec systemd_test useradd testuser
223 % podman exec systemd_test sh -c "echo 'testuser:password' | chpasswd"
224
225 % ctr task exec --exec-id test_exec my_systemd_container useradd testuser
226 % ctr task exec --exec-id test_exec my_systemd_container sh -c "echo 'testuser:password' | chpasswd"
227 % ctr task exec -t --exec-id test_exec my_systemd_container bash
228
229Get the IP address:
230
231 % root@qemuarm64-54:~# docker inspect systemd_test | grep \"IPAddress\":
232 "IPAddress": "172.17.0.2",
233 "IPAddress": "172.17.0.2",
234
235 % root@qemuarm64-54:~# podman inspect 2f9e00c53c13 | grep IPAdd
236 "IPAddress": "10.88.0.5",
237 "IPAddress": "10.88.0.5",
238
239ssh into the container:
240
241 % root@qemuarm64-54:~# ssh testuser@172.17.0.2
242 % testuser@172.17.0.2's password:
243
244 WARNING: Poky is a reference Yocto Project distribution that should be used for
245 testing and development purposes only. It is recommended that you create your
246 own distribution for production use.
247
248 4b07cc907e26:~$ systemctl | grep running
249 init.scope loaded active running System and Service Manager
250 session-c1.scope loaded active running Session c1 of User testuser
251 dbus.service loaded active running D-Bus System Message Bus
252 dhcpcd.service loaded active running A minimalistic network configuration daemon with DHCPv4, rdisc and DHCPv6 support
253 getty@tty1.service loaded active running Getty on tty1
254 sshd@2-172.17.0.2:22-172.17.0.1:39264.service loaded active running OpenSSH Per-Connection Daemon (172.17.0.1:39264)
255 systemd-journald.service loaded active running Journal Service
256 systemd-logind.service loaded active running User Login Management
257 systemd-networkd.service loaded active running Network Configuration
258 systemd-nsresourced.service loaded active running Namespace Resource Manager
259 systemd-resolved.service loaded active running Network Name Resolution
260 systemd-userdbd.service loaded active running User Database Manager
261 user@1000.service loaded active running User Manager for UID 1000
262 xinetd.service loaded active running Xinetd A Powerful Replacement For Inetd
263 dbus.socket loaded active running D-Bus System Message Bus Socket
264 systemd-journald-dev-log.socket loaded active running Journal Socket (/dev/log)
265 systemd-journald.socket loaded active running Journal Sockets
266 systemd-networkd.socket loaded active running Network Service Netlink Socket
267 systemd-nsresourced.socket loaded active running Namespace Resource Manager Socket
268 systemd-userdbd.socket loaded active running User Database Manager Socket
269
270
271 % root@qemuarm64-54:~# ssh testuser@10.88.0.5
272 The authenticity of host '10.88.0.5 (10.88.0.5)' can't be established.
273 ECDSA key fingerprint is SHA256:ydCJGSVNLdWiAcC5PUkDsiFZZ6sDTeQ9Nt13a6HQCc4.
274 This key is not known by any other names.
275 Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
276 Warning: Permanently added '10.88.0.5' (ECDSA) to the list of known hosts.
277 testuser@10.88.0.5's password:
278
279 WARNING: Poky is a reference Yocto Project distribution that should be used for
280 testing and development purposes only. It is recommended that you create your
281 own distribution for production use.
282
283 2f9e00c53c13:~$
284
285Enjoy!
286
287