Skip to content

Commit

Permalink
Use alternative method for systemd v248
Browse files Browse the repository at this point in the history
  • Loading branch information
saville committed Nov 12, 2024
1 parent b936491 commit 995a0b7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions buildrunner/docker/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,18 @@ def start(
security_opt = None
command = shell
tmpfs = {}
cgroupns = None
if systemd:
# If we are running in a systemd context, the following 3 settings are necessary to
# allow services to run.
volumes[
"/sys/fs/cgroup"
] = f"/sys/fs/cgroup:{'rw' if systemd_v248 else 'ro'}"
security_opt = ["seccomp=unconfined"]
command = "/usr/sbin/init"
if systemd_v248:
volumes["/sys/fs/cgroup/buildrunner.scope"] = "/sys/fs/cgroup:rw"
tmpfs["/run"] = ""
cgroupns = "host"
else:
volumes["/sys/fs/cgroup"] = "/sys/fs/cgroup:ro"
security_opt = ["seccomp=unconfined"]
command = "/usr/sbin/init"

if volumes:
for key, value in volumes.items():
Expand Down Expand Up @@ -219,6 +221,7 @@ def start(
"user": user,
"working_dir": working_dir,
"hostname": hostname,
"cgroupns": cgroupns,
"host_config": self.docker_client.create_host_config(
binds=_binds,
links=links,
Expand Down

0 comments on commit 995a0b7

Please sign in to comment.