Skip to content

Commit 79deab3

Browse files
committed
add example dockerfile with podman rootless
1 parent 15f74e9 commit 79deab3

File tree

1 file changed

+67
-0
lines changed
  • test-images/alpine-openrc-podman-cli-rootless

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
FROM docker.io/alpine:3.22
2+
ARG TARGETPLATFORM
3+
4+
RUN apk add --no-cache \
5+
openrc \
6+
mdevd-openrc \
7+
wget \
8+
curl \
9+
bash \
10+
sudo \
11+
jq \
12+
dasel \
13+
shadow \
14+
podman \
15+
podman-compose \
16+
# Required when running inside docker
17+
# see https://github.com/containers/buildah/issues/3666
18+
fuse-overlayfs \
19+
# Add packages which are required for rootless
20+
shadow-uidmap \
21+
iproute2 \
22+
ip6tables \
23+
&& wget -O - thin-edge.io/install.sh | sh -s \
24+
&& apk add \
25+
tedge-apk-plugin \
26+
tedge-command-plugin
27+
28+
ADD https://raw.githubusercontent.com/thin-edge/tedge-demo-container/refs/heads/main/images/common/bootstrap.sh /usr/bin/
29+
RUN chmod 755 /usr/bin/bootstrap.sh
30+
31+
RUN sed -i '/getty/d' /etc/inittab \
32+
&& sed -i 's/#mount_program/mount_program/' /etc/containers/storage.conf
33+
34+
COPY dist/*.apk /tmp/
35+
RUN case ${TARGETPLATFORM} in \
36+
"linux/386") PKG_ARCH=linux_386 ;; \
37+
"linux/amd64") PKG_ARCH=linux_amd64 ;; \
38+
"linux/arm64") PKG_ARCH=linux_arm64 ;; \
39+
"linux/arm/v6") PKG_ARCH=linux_armv6 ;; \
40+
"linux/arm/v7") PKG_ARCH=linux_armv7 ;; \
41+
*) echo "Unsupported target platform: TARGETPLATFORM=$TARGETPLATFORM"; exit 1 ;; \
42+
esac \
43+
&& apk add --allow-untrusted /tmp/*${PKG_ARCH}*.apk \
44+
&& mkdir -p /opt/packages \
45+
&& cp /tmp/*${PKG_ARCH}*.apk /opt/packages/ \
46+
&& rm -f /tmp/*.apk
47+
48+
RUN echo "tedge ALL = (ALL) NOPASSWD: /usr/bin/tedge-container" | tee /etc/sudoers.d/tedge-containers \
49+
&& mkdir -p /etc/tedge-container-plugin \
50+
&& echo "CONTAINER_METRICS_INTERVAL=60s" | tee -a /etc/tedge-container-plugin/env \
51+
&& dasel put -r toml -t string -v '60s' 'metrics.interval' --indent 0 < /etc/tedge/plugins/tedge-container-plugin.toml > /etc/tedge/plugins/tedge-container-plugin.toml.tmp \
52+
&& mv /etc/tedge/plugins/tedge-container-plugin.toml.tmp /etc/tedge/plugins/tedge-container-plugin.toml
53+
54+
# Setup podman rootless for the tedge user
55+
RUN mkdir -p /home/tedge/.config/containers/ \
56+
&& chown -R tedge:tedge /home/tedge \
57+
&& usermod --add-subuids 100000-165535 --add-subgids 100000-165535 tedge \
58+
&& sed -i 's/.*podman_user=.*/podman_user="tedge"/g' /etc/conf.d/podman \
59+
&& sed -i 's/.*command_user=.*/command_user="tedge"/g' /etc/conf.d/tedge-container-plugin \
60+
# Workaround: disable modprobe checks due to an issue with /lib/modules not being present
61+
# possibly due to running podman within docker?
62+
&& sed -i 's/modprob/#modprobe/g' /etc/init.d/podman
63+
64+
# Default services
65+
RUN rc-update add podman
66+
67+
CMD ["/sbin/init"]

0 commit comments

Comments
 (0)