You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there any way to run systemd inside the container? I tried using an image with systemd but it exits with code (255) and I couldn't find any error in any logs. I tried using crt instead of docker but the result was the same.
My end goal is to have systemd running inside a kata container in k8s, but I started experimenting with it on a local machine.
Any hints and tips are highly appreciated! I've been struggling with this for a couple of days now :(
This is the command I ran: docker run --rm -it --runtime io.containerd.kata.v2 -it docker.io/nestybox/ubuntu-jammy-systemd
This is the image I used:
# Sample container image with Ubuntu Jammy + Systemd
#
# Description:
#
# This image serves as a basic reference example for user's looking to
# run Systemd inside a system container in order to deploy various
# services within the system container, or use it as a virtual host
# environment.
#
# Usage:
#
# $ docker run --runtime=sysbox-runc -it --rm --name=syscont nestybox/ubuntu-jammy-systemd
#
# This will run systemd and prompt for a user login; the default user/password
# in this image is "admin/admin".
FROM ubuntu:jammy
#
# Systemd installation
#
RUN apt-get update && \
apt-get install -y --no-install-recommends \
systemd \
systemd-sysv \
libsystemd0 \
ca-certificates \
dbus \
iptables \
iproute2 \
kmod \
locales \
sudo \
udev && \
\
# Prevents journald from reading kernel messages from /dev/kmsg
echo "ReadKMsg=no" >> /etc/systemd/journald.conf && \
\
# Housekeeping
apt-get clean -y && \
rm -rf \
/var/cache/debconf/* \
/var/lib/apt/lists/* \
/var/log/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/man/* \
/usr/share/local/* && \
\
# Create default 'admin/admin' user
useradd --create-home --shell /bin/bash admin && echo "admin:admin" | chpasswd && adduser admin sudo
# Disable systemd services/units that are unnecessary within a container.
RUN systemctl mask systemd-udevd.service \
systemd-udevd-kernel.socket \
systemd-udevd-control.socket \
systemd-modules-load.service \
sys-kernel-debug.mount \
sys-kernel-tracing.mount
# Make use of stopsignal (instead of sigterm) to stop systemd containers.
STOPSIGNAL SIGRTMIN+3
# Set systemd as entrypoint.
ENTRYPOINT [ "/sbin/init", "--log-level=err" ]
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is there any way to run systemd inside the container? I tried using an image with systemd but it exits with code
(255)
and I couldn't find any error in any logs. I tried using crt instead of docker but the result was the same.My end goal is to have systemd running inside a kata container in k8s, but I started experimenting with it on a local machine.
Any hints and tips are highly appreciated! I've been struggling with this for a couple of days now :(
Similar question asked here: #7357
This is the command I ran:
docker run --rm -it --runtime io.containerd.kata.v2 -it docker.io/nestybox/ubuntu-jammy-systemd
This is the image I used:
Beta Was this translation helpful? Give feedback.
All reactions