Gitlab-runner / docker / systemd


#1

Hi,
I try to get this minimal .gitlab-ci.yml pipeline project running:

deploy:centos7:
image: centos/systemd
script:
- systemctl status

My gitlab-runner configuration looks as follows:
cat /etc/gitlab-runner/config.toml
concurrent = 4
check_interval = 0

[[runners]]
name = “docker"
url = “https://host.example.com"
token = “ba3s974a9a41d8e1ca3da852a82ba2"
executor = “docker”
[runners.docker]
tls_verify = false
image = “docker:latest"
privileged = true
disable_cache = false
volumes = [”/sys/fs/cgroup:/sys/fs/cgroup:ro”,”/cache”]
shm_size = 0
[runners.cache]

The job always results in:
$ systemctl status
Failed to get D-Bus connection: Operation not permitted
ERROR: Job failed: exit code 1

What am I doing wrong?

Cheers Jonas


#2

You cannot use systemctl inside docker. Systemctl is part of Systemd, but Docker images generally do not have systemd running.


#3

$ docker run --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -d centos/systemd
bd0435084d4b664cc752771c27b9d44a6ca4fdda6d48d1515d4dc8dff520dc49

$ docker exec -it bd0435084d4b bash
[root@bd0435084d4b /]# systemctl status
● bd0435084d4b
State: running
Jobs: 0 queued
Failed: 0 units
Since: Mon 2017-08-14 11:09:14 UTC; 17s ago
CGroup: /docker/bd0435084d4b664cc752771c27b9d44a6ca4fdda6d48d1515d4dc8dff520dc49
├─ 1 /usr/sbin/init
├─26 bash
├─39 systemctl status
├─40 systemctl status
└─system.slice
└─systemd-journald.service
└─18 /usr/lib/systemd/systemd-journald

Sure it works, there are specialised container images, which support running systemd inside the container.


#4

hey @MrRagga did you ever figure this out?


#5

Hey Steve,
no sadly no progress on this issue. But I still would love to get it running.

Can’t believe that there are no people who have the same issue to be able to test services with native systemd support.
My current workaround is:

  • write systemd unit file
  • take the command from the unit file, run it manually and don’t start the service via systemd itself.

Cheers Jonas


#6

I’m looking at some redhat docs here and I’ve added /tmp and /run as temps volumes and I’m still seeing the same things as you.

My use case is that I’m building an RPM and would like to be able to install it into a docker image and run goss to test to see whether the RPM can start services and the like. Works great for local testing but I can’t make it go in gitlab-ci.