i am creating a Dockerfile that downloads Debian:bookworm and i running a program through apt, but when it finishes the build, i am getting the following error:
**0.738 System has not been booted with systemd as init system (PID 1). Can't operate.**
**0.738 Failed to connect to bus: Host is down**
A container is not a virtual machine so you canât use it like that. Systemd is something that runs as the very first process on top of a Linux kernel to handle all the other processes in most of the modern Linux distributions, but not in an application container which is an isolated environment for a process and not an entire operating system.
If you want something that allows you to install almost everything as you would do on a physical machine or in a virtual machine, you can try âsystem containersâ. Docker is for application containers. LXD and Incus are for system containers.
In a Docker container you (almost always) run processes without Systemd. If you need multiple processes in a single container, you can try Supervisor or s6-init for example.
If you want to know why you should not use Systemd in a Docker container, you can search for systemd on the forum, or read my tutorial that includes systemd as well
I never tried, but Podman claims to be able to run Systemd more easily
What exactly do you want to run in a container? You can use a base image which already contains what you need and built for starting the process properly.
What i am trying to achieve is to build Jenkins docker by using the repo, not the Java (WAR file). That will give me the ability to upgrade it via apt-get. Here is my Dockerfile:
#Ude Debian slim latest
FROM debian:bookworm-slim
#Update & upgrade
RUN apt-get update && apt-get upgrade -y
#Install needed packages
RUN apt-get install -y --no-install-recommends gnupg openjdk-17-jdk fontconfig openjdk-17-jre apt-transport-https wget curl screen htop nano vim sudo procps lsb-release
#Keyring & repo config
RUN wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian/jenkins.io-2023.key
RUN echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" https://pkg.jenkins.io/debian binary/ | tee /etc/apt/sources.list.d/jenkins.list > /dev/null
# Install Jenkins
RUN apt update && apt install jenkins -y
EXPOSE 8080/tcp
EXPOSE 8080/udp
EXPOSE 50000/tcp
EXPOSE 50000/udp
I would like to be able to directly hit from the browser the Systemâs IP (where docker is running) http://IP_address:8080 and get jenkins. I have seen that the Jenkins is already available, but it does not use the apt-get, rather it uses the java environment.
Dear @bluepuma77, thanks a lot for the reply, but i am afraid you missed my statement: to be able to use the apt-get utility and update jenkins, instead of getting pinned to a certain version and manually downloading a Java file and executing it.
That is probably the right way anyway, at least in this case. APT repositories change, packages disappear and you have no total control over which version you install. I feel your real question is how you can properly update a Docker image, using APT is just a way you imagined you could solve it.
I donât think he missed your point. He is trying to tell you how you should work with containers. I recommend taking his words, nobody talks about downloading a WAR file, just use an already existing image. When you want to update it, you pull a new version. You can decide how specific image version you use, you can even automate the update with a proper pipeline.
Use official existing images when you can, learn about crating your own images, customize existing images and make your own base image only when you know why you need it.
You chose to use containers, and thatâs the way Donât make your life harder by sticking to solutions you used without containers.
The title of the topic is âDockerfile with Debian & Systemdâ. I donât know anyone who uses systemd in a container in production. I used it only in special cases years ago, but Jenkins is not really special