Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to create /init.scope control group: Read-only file system #122

Open
roberth opened this issue Jun 7, 2021 · 5 comments
Open

Failed to create /init.scope control group: Read-only file system #122

roberth opened this issue Jun 7, 2021 · 5 comments

Comments

@roberth
Copy link
Member

roberth commented Jun 7, 2021

To reproduce

  1. start a systemd-based container on NixOS 21.05
  2. observe the error message in the log
Failed to create /init.scope control group: Read-only file system
Failed to allocate manager object: Read-only file system
[!!!!!!] Failed to allocate manager object.
Exiting PID 1...

Cause

Systemd and docker have become incompatible since 21.05 and cgroupsv2.

Previously, the systemd and docker teams have disagreed about how the two should work together, so I don't expect the root cause to be resolved soon. Luckily, not the whole container ecosystem thinks about containers like docker does.

Solution

Arion >=0.1.3.0 creates containers in such a way that they do work in Podman. Podman is maintained by Red Hat, so its systemd support isn't going away anytime soon.

Start by installing podman in your NixOS configuration:

{
  virtualisation.podman.enable = true;
  virtualisation.podman.defaultNetwork.dnsname.enable = true;
  # Use your username instead of `myuser`
  users.extraUsers.myuser.extraGroups = ["podman"];
}

If you want to replace Docker by Podman entirely, use:

{
  virtualisation.podman.dockerSocket.enable = true;
  environment.systemPackages = [
     pkgs.docker-client
  ];
}

Or if you want to use them side by side, switch to Podman with:

export DOCKER_HOST=unix:///run/podman/podman.sock

and switch to local docker with:

unset DOCKER_HOST

Or add it to shell.nix for projects that need Podman.

pkgs.mkShell {  # using mkShell for example; most derivation-producing functions work the same
  # ...
  DOCKER_HOST = "unix:///run/podman/podman.sock";
}
@roberth roberth pinned this issue Jun 7, 2021
@zimbatm
Copy link
Contributor

zimbatm commented Aug 30, 2021

If you just want things to work again before finding a permanent solution, setting systemd.enableUnifiedCgroupHierarchy = false; and rebooting should also work around the issue.

@gbtb
Copy link

gbtb commented Dec 20, 2022

I want to add that if you are installing podman for NixOS first time you have to reboot, because otherwise docker compat socket is not accessible with some permission errors. Perhaps this should be added to the docs as well.

@Silver-Golden
Copy link

I want to add that if you are installing podman for NixOS first time you have to reboot, because otherwise docker compat socket is not accessible with some permission errors. Perhaps this should be added to the docs as well.

Thank you thank you thank you, you saved me.
I have been debugging for ages why this wasnt working well and rebooting was teh solution.

@deliciouslytyped
Copy link

It's possible to do this rootless by setting DOCKER_HOST to /run/user/$(id -u)/podman/podman.sock .

@KiaraGrouwstra
Copy link
Contributor

systemd dropping cgroup v1 seems to now make arion yield:

Legacy cgroup v1 support selected. This is no longer supported. Will proceed anyway after 30s

to address this, i tried:

  • systemd.enableUnifiedCgroupHierarchy = false;
  • DOCKER_HOST="unix:///run/podman/podman.sock" (using global podman install)
  • PODMAN_IGNORE_CGROUPSV1_WARNING=1

podman seems to also have a --cgroups=disabled, tho i hadn't figured out yet how to set that yet thru arion.

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

No branches or pull requests

6 participants