Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

systemctl not working in container - 'Failed to connect to bus: No such file or directory' #2

Closed
geerlingguy opened this issue Oct 23, 2018 · 6 comments

Comments

@geerlingguy
Copy link
Owner

With the current image and default init command, I get the following:

# systemctl status
Failed to connect to bus: No such file or directory

And when running an Ansible playbook which manages a service:

TASK [geerlingguy.docker : Ensure Docker is started and enabled at boot.] ******
fatal: [instance]: FAILED! => {"changed": false, "cmd": "/usr/bin/systemctl", "msg": "Failed to connect to bus: No such file or directory", "rc": 1, "stderr": "Failed to connect to bus: No such file or directory\n", "stderr_lines": ["Failed to connect to bus: No such file or directory"], "stdout": "", "stdout_lines": []}

Looking into the issue, it seems dbus-daemon may not be running.

But if I do the following:

mkdir -p /run/dbus
dbus-daemon --system

It seems to start, but then I get:

# systemctl status
Failed to read server status: Launch helper exited with unknown return code 1
@geerlingguy
Copy link
Owner Author

So this image—which seems almost identical to my current build—currently works out of the box: https://hub.docker.com/r/unop/fedora-systemd/

@geerlingguy
Copy link
Owner Author

Looks like it might just be the init command...

-CMD ["/usr/lib/systemd/systemd"]
+CMD ["/usr/sbin/init"]

@geerlingguy
Copy link
Owner Author

Simply running the container seems to work now. But in my molecule environment it is not. Might be a volume binding issue.

@JimmyTournemaine
Copy link

Same issues using geerlingguy/docker-centos8-ansible docker image using molecule.
Using CMD: ["/usr/sbin/init"] fix it too.

- name: instance
    image: "geerlingguy/docker-centos8-ansible:latest"
    command: ${MOLECULE_DOCKER_COMMAND:-"/usr/sbin/init"}
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    privileged: true
    pre_build_image: true

@geerlingguy
Copy link
Owner Author

@JimmyTournemaine - Please consider filing an issue against that repository—if there's something it can fix: https://github.com/geerlingguy/docker-centos8-ansible

@JimmyTournemaine
Copy link

In fact, my goal here was more to leave a note that could be useful to others because I came across this issue while looking for the solution to this problem but with another image.
As the issue was closed, I didn't see the point of creating it again on another repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants