-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
podman rootless startup: missing dependency in systemd PATH #138423
Comments
I'm having the same issue with rootless podman containers launched by systemd. Following configuration snippet could be used for a simple repro: { pkgs, ... }: let
user = "test";
group = "test";
container = "rootless-podman-test";
service = {
serviceConfig = {
User = user;
Group = group;
Type = "oneshot";
};
script = "${pkgs.podman}/bin/podman run --name ${container} --replace --rm docker.io/library/hello-world:latest";
preStop = "${pkgs.podman}/bin/podman stop ${container}";
};
in {
systemd.services = {
rootless-podman-test1 = service;
rootless-podman-test2 = service // {
path = [ pkgs.shadow ];
};
};
users = {
groups.${group} = {};
users.${user} = {
isNormalUser = true;
group = group;
};
};
}
So if the If I try to launch same container manually, it works fine:
|
Ok, looks like the issue was that the I'm able to successfully run rootless containers using following configuration: { pkgs, ... }: let
user = "test";
group = "test";
container = "rootless-podman-test";
in {
systemd.services.rootless-podman-test = {
path = [ "/run/wrappers" ];
serviceConfig = {
User = user;
Group = group;
Type = "oneshot";
};
script = "${pkgs.podman}/bin/podman run --name ${container} --replace --rm docker.io/library/hello-world:latest";
preStop = "${pkgs.podman}/bin/podman stop ${container}";
};
users = {
groups.${group} = {};
users.${user} = {
isNormalUser = true;
group = group;
};
};
} |
I marked this as stale due to inactivity. → More info |
Any info on this? |
@binarycode's solution works on file systems which support xattrs. If you are on a filesystem which does not support xattrs, such as
To fix this, follow the StackOverflow answer, i.e., add { pkgs, ... }: let
user = "test";
group = "test";
container = "rootless-podman-test";
in {
systemd.services.rootless-podman-test = {
path = [ "/run/wrappers" ];
serviceConfig = {
User = user;
Group = group;
Type = "oneshot";
};
script = ''${pkgs.podman}/bin/podman \
--storage-opt "overlay.mount_program=${pkgs.fuse-overlayfs}/bin/fuse-overlayfs" run \
--name ${container} --replace --rm docker.io/library/hello-world:latest
'';
preStop = "${pkgs.podman}/bin/podman stop ${container}";
};
users = {
groups.${group} = {};
users.${user} = {
isNormalUser = true;
group = group;
};
};
} Another option, as mentioned in the StackOverflow answer, is to format your filesystem, or part of it. Mentioning this in case someone wants to write a PR on the original topic, as the same PR should likely address this edge-case as well. |
See NixOS/nixpkgs#138423 Potentially a security issue as `/run/wrappers/bin/` contains more commands often with suid bit set.
…user lingering Systemd's user lingering feature seems to be necessary to run rootless podman if the executing user is not logged in. See NixOS/nixpkgs#138423
podman and systemd --user is a f*%?ing mess !! i'm trying to do a simple thing : running podman container with systemd user unit, but nothing work :( open to suggestions... |
same issue here in a nix shell.
also open to suggestions edit: error was produced on Ubuntu 20.04, seems to work fine for Fedora 37 |
This issue seems to have been resolved in the latest release (23.05), probably by #215588 |
@maxbrunet is this already released? I also just installed in my fresh Debian with: I have nix (Nix) 2.16.1 and it installed podman version 4.5.1. |
Podman cannot be used with the package only, configuration around it is required: This issue is for NixOS I believe. On Debian, you would need to write a module yourself or use a Debian package ( From the module, you would need to install it this way: (pkgs.podman.override {
extraPackages = [
# setuid shadow
"/run/wrappers"
]
}) Not sure what is the minimum config to get it running and if |
Question out of being a noob in nixpkgs, does someone know a way to run this override from @maxbrunet in imperative |
This is strongly inspired by NixOS/nixpkgs#138423
This is sad, I am also using nix package manager on Debian.. but I do not have knowledge to write a module, from what I understood of nix package manager it should be able to have packages working independent of OS, in really I do not see this happening in the example of this issue. Btw I also tried on Mac M1 ARM, same issue on MacOS, this is a pain. It also noticed there is no word from the maintainers on this issue.. |
Describe the bug
I'm on nixos unstable
I'm trying to start a rootless podman container via podman. basically define a podman container the nix way, but starting it from a user.
Podman can not start because it needs the
newuidmap
binary (from theshadow
package, which is not in thePATH
of the systemd:Note: all works if we start the same container with the root user
Steps To Reproduce
Steps to reproduce the behavior:
nix-rebuild switch
journactl -eu podman-alpine
Expected behavior
The podman container starts under the given user.
Additional context
This part is only for those that want to try with a more stable setup, and can be ignored as long as you login as your podman user before starting the podman container
Adapted from here: https://serverfault.com/questions/892465/starting-systemd-services-sharing-a-session-d-bus-on-headless-system
Basically we need to create a valid systemd user session for your podman user, and a dbus one, too
I did not create the systemd-user files like the guide above, but relied on system-level ones since the nix configuration only generates units on system level, not at user level AFAIK
Notify maintainers
@adisbladis
@saschagrunert
@vdemeester
@zowoq
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.The text was updated successfully, but these errors were encountered: