0

I am trying to start a Debian image with the /sbin/init process for ansible role testing via molecule.

Yes, I am aware, that one should not start /sbin/init in a container unless you really have a use case for doing so. With molecule I can test my ansible roles in a docker container. As such I need /sbin/init running.

When I execute

docker run -it --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro debian:9 /sbin/init

docker: Error response from daemon: OCI runtime create failed: container_linux.go:346:
starting container process caused "exec: \"/sbin/init\": stat /sbin/init: no such file 
or directory": unknown.

However, with debian:8 it works just fine.

docker run -it --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro debian:8 /sbin/init

works like a charm.

Has Debian switched to a new boot process? What changed?

ckaserer
  • 4,827
  • 3
  • 18
  • 33

1 Answers1

5

Turns out Debian has removed the init package from their docker images starting with debian:9 and newer.

That is great since it helps all of us to fail early/fast. We really should not start /sbin/init unless we have a use-case for doing so - and believe me, most of the time we do not.

So what to do if we really have a use-case in which we need to run /sbin/init?

Well, we can install it via

apt-get install -y init

If you need a Dockerfile for that

FROM debian:9

RUN apt-get update && apt-get install -y init && apt-get clean all
ckaserer
  • 4,827
  • 3
  • 18
  • 33
  • 1
    You need /sbin/init for any kind of Ansible testing that involves systemd (i.e. pretty much all of my playbooks). – bviktor Oct 11 '22 at 20:58
  • 1
    it would help a lot if you could explain and provide resources from where we can read, why `init` inside a docker container is so dangerous. – woodz Nov 22 '22 at 10:40