Skip to content

Conversation

@rumpl
Copy link
Member

@rumpl rumpl commented Apr 4, 2023

- What I did

Set the process user on exec

This change makes is possible to run docker exec -u <UID> ... when the containerd integration is activated.

- How I did it

We load the container spec and change its user and then set the exec process user.

- How to verify it

$ docker run -d --rm -it ubuntu /bin/bash
f986fab0f34af0d235a10a7df32199f54d79a4da4d1984b85bcab5fd5fffbe27
$ docker exec -u 1000 f986fab0f34af0d235a10a7df32199f54d79a4da4d1984b85bcab5fd5fffbe27 id
uid=1000 gid=0(root) groups=0(root)

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@rumpl rumpl added area/runtime Runtime containerd-integration Issues and PRs related to containerd integration labels Apr 4, 2023
@rumpl rumpl added this to the 24.0.0 milestone Apr 4, 2023
@rumpl rumpl marked this pull request as draft April 4, 2023 14:12
@rumpl
Copy link
Member Author

rumpl commented Apr 4, 2023

Converting to draft for now, this one needs this too rumpl#92

@rumpl
Copy link
Member Author

rumpl commented Apr 5, 2023

I opened a PR in containerd containerd/containerd#8351

rumpl added 2 commits April 7, 2023 10:53
This change makes is possible to run `docker exec -u <UID> ...` when the
containerd integration is activated.

Signed-off-by: Djordje Lukic <[email protected]>
Uses containerd from release/1.6 commit containerd/containerd@c0efc63

Signed-off-by: Djordje Lukic <[email protected]>
@rumpl rumpl force-pushed the c8d-fix-exec-user branch from 32daa66 to be4abf9 Compare April 7, 2023 08:58
@rumpl rumpl marked this pull request as ready for review April 7, 2023 08:59
@rumpl
Copy link
Member Author

rumpl commented Apr 7, 2023

The readonly mount in containerd was merged in master and 1.6 and 1.7 release branches, I updated the dependency to containerd/containerd@c0efc63, exec-ing into a container with a user now works and doesn't put the mounts into an undefined state.

if err != nil {
return err
if daemon.UsesSnapshotter() {
p.User, err = getUserFromContainerd(ctx, daemon.containerdCli, ec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this one also work for !daemon.UsesSnapshotter() branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok just tested and indeed this can work for both cases, will update

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather we didn't actually, we can do it in the future once we are sure that the two ways of getting the users and groups are equivalent, I can add a TODO though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it might be better not to touch the non-snapshotter case. I was just asking out of curiosity 😄

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (I guess technically the commits should have been in the reverse order, but the first one "builds", so I guess it's fine)

@thaJeztah thaJeztah merged commit 860db98 into moby:master Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/runtime Runtime containerd-integration Issues and PRs related to containerd integration

Projects

Development

Successfully merging this pull request may close these issues.

3 participants