geerlingguy / docker-ubuntu1804-ansible

Ubuntu 18.04 LTS (Bionic) Docker container for Ansible playbook and role testing.
https://hub.docker.com/r/geerlingguy/docker-ubuntu1804-ansible/
MIT License
79 stars 53 forks source link

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

Open kozicpetar opened 2 years ago

kozicpetar commented 2 years ago

Hi, I'm using this image for a while for my ansible roles and now I have issue which I didn't get before.

I get error:

fatal: [Ubuntu-18.04]: FAILED! => {"changed": false, "cmd": "/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": []}

This is my molecule file, with privileged and ro cgroup:

platforms:
  - name: Ubuntu-18.04
    image: geerlingguy/docker-ubuntu1804-ansible:latest
    command: ${MOLECULE_DOCKER_COMMAND:-""}
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    privileged: true
    pre_build_image: true

When I login to container and run systemctl I get error:

Failed to connect to bus: No such file or directory

Same error I get for container geerlingguy/docker-debian10-ansible:latest

kozicpetar commented 2 years ago

Looks like that is related with this issue for 20.04 also: https://github.com/geerlingguy/docker-ubuntu2004-ansible/issues/6

and if I understood that is related with new version of Docker.

Can we do something on image to bypass this problem?

p3l1 commented 2 years ago

What version of Docker are you using? I've got the same problem on macOS with Docker Desktop 4.5.0 on Apple Silicon. Its currently the latest version.

p3l1 commented 2 years ago

For now I found another solution using docker-systemctl-replacement. It's quite easy to integreate in an existing Molecule test. Here are the documentation and the instructions i followed.