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

Include support for rootless container and user creation in oci-containers #112902

Open
bryanasdev000 opened this issue Feb 12, 2021 · 15 comments
Open
Labels
0.kind: bug Something is broken

Comments

@bryanasdev000
Copy link
Member

Describe the bug

In the current mode with podman, we define the specifications of our container and it goes up with the root user, ideally it would have a podman user or even better, one user per container, this would help in abstraction and allow to execute the containers with a service view.

To Reproduce
Steps to reproduce the behavior:

  1. Add this to your configuration.nix:
  virtualisation.oci-containers.backend = "podman";
  virtualisation.oci-containers.containers = {
    tester = {
      image = "pengbai/docker-supermario";
      ports = [ "8090:8080" ];
    };
  };
  1. nixos-rebuild switch
  2. ps aux | grep mario

Mario container will be running as root.

Expected behavior

Mario container will be running under user podman or podman-tester (podman+container name).

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Notify maintainers

@adisbladis

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.10-zen1, NixOS, 21.03pre268835.8c8731330b5 (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.10`
 - channels(root): `"nixos-21.03pre268835.8c8731330b5, home-manager"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module: oci-containers
@bryanasdev000 bryanasdev000 added the 0.kind: bug Something is broken label Feb 12, 2021
@adisbladis
Copy link
Member

While I agree with the issue I don't think it's possible to do this in a way that's also compatible with the docker backend.

@bryanasdev000
Copy link
Member Author

While I agree with the issue I don't think it's possible to do this in a way that's also compatible with the docker backend.

Perhaps, Docker 20.10 supports rootless mode, despite having some limitations it seems usable.
(https://docs.docker.com/engine/security/rootless/)

But would it be a problem to have this only for Podman?

@adisbladis
Copy link
Member

But would it be a problem to have this only for Podman?

No, but no other options are only supported by one backend at the moment. Ideally we'd only have options compatible with both.

Perhaps, Docker 20.10 supports rootless mode, despite having some limitations it seems usable.

That's news to me. Great!

@bryanasdev000
Copy link
Member Author

But would it be a problem to have this only for Podman?

No, but no other options are only supported by one backend at the moment. Ideally we'd only have options compatible with both.

Perhaps, Docker 20.10 supports rootless mode, despite having some limitations it seems usable.

That's news to me. Great!

I will try to run some tests here, are you okay with one user per container?

@adisbladis
Copy link
Member

adisbladis commented Feb 12, 2021

I will try to run some tests here, are you okay with one user per container?

Couldn't we just run them with systemd's dynamicuser feature? It may be that this is not possible because of subuid/subgid requirements.

cc @saschagrunert

@bryanasdev000
Copy link
Member Author

I will try to run some tests here, are you okay with one user per container?

Couldn't we just run them with systemd's dynamicuser feature? It may be that this is not possible because of subuid/subgid requirements.

cc @saschagrunert

Hmm, thanks for the dose of knowledge, I didn't know about the dynamic user.

However I believe that at first it would not work for containers with volume, correct?

I imagine that we would have many *IDs in the equation.

@saschagrunert
Copy link
Member

Hm, maybe this feature could help us here:
containers/podman#7778

But would it be a problem to have this only for Podman?

No, but no other options are only supported by one backend at the moment. Ideally we'd only have options compatible with both.

I think this is a blocker for now.

@bryanasdev000
Copy link
Member Author

Hm, maybe this feature could help us here:
containers/podman#7778

But would it be a problem to have this only for Podman?

No, but no other options are only supported by one backend at the moment. Ideally we'd only have options compatible with both.

I think this is a blocker for now.

I didn't understand in this case how it would look if I used two replicas of the same container, would they conflict with the volume's UID?

And I understood about the docker issue, it would be, at first, an exclusive feature of the podman.

I will run some tests with the rootless docker.

@bryanasdev000
Copy link
Member Author

I think a service account for general management is also a possibility, for example, a podman and docker user.

@stale
Copy link

stale bot commented Aug 15, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 15, 2021
@bryanasdev000
Copy link
Member Author

Up.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 17, 2021
@stale
Copy link

stale bot commented Apr 29, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 29, 2022
@dzmitry-lahoda
Copy link

some scripts use docker as build system, so it would be fast track for nixification before going nix deep

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 20, 2022
@claes
Copy link
Contributor

claes commented Nov 14, 2022

Related: #138423

@felixsanz
Copy link

it is not possible to just add an option like podmanUser: "1000:100"; and use that User inside systemd's generated service file? the podman run command will be executed by the user specified in that option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

6 participants