You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When executing a task with non-root user, inputs should be owned by that user #403
We are using a Docker image with a non-root user (Dockerfile contains a "USER" command). All inputs (e.g. obtained by the git resource) are owned by root. Therefore, to make a commit we need to chown all files first. It seems like Concourse should do that for me when mounting the inputs.
Reacted by George Haidar, Gregory Arcara, Kyle Li, Daniel Miranda, Jim Myers, Johannes Pfau, miromode, Ash Berlin-Taylor, william light, Florent Biville and 35 more
I've started working on this and have a WIP branch here: master...403-chown
The basics work, but now I'm thinking about how this will affect existing workloads. What I've written currently chown's every bind mount to the user the task will run as. I'm wondering if I should do nothing if the user is running as root inside the container? I don't touch permissions of the rootfs.
Vito had mentioned there may be issues with volumes storing git repos. I looked into this and I don't think it'll be an issue. Git doesn't track file ownership at all.
I guess the main concern I have is: are there cases where we shouldn't chown a volume at all? Vito's comment here is my main concern:
@miromode the root-escape bugs in docker might not affect Concouse as it uses it's own container runtime (caled "garden") to run containers, not docker, so there's a chance that the same bugs won't exist here. (Or they could share the same code from libcontainer and might be vulnerable. I don't know at either way)
I have hit this issue trying to use gradle image to build a gradle project, can work around it by specifying root, but I don't like being forced to do so. I think this is a bug, you have different behaviour when running gradle via docker docker run --rm -v "$PWD":/project -w /project --name gradle gradle:alpine gradle <gradle-task>
This is not consistent.
Nope, no progress on this. Anyone is free to pick this up and work on it. I'll happily review any PR improving this.
I haven't dug into this at all so no suggestions for implementation. It'd be nice if this can be fully resolved within baggageclaim, but I think we'll need the runtime to fetch the user info for us.
I've started working on this and have a WIP branch here: master...403-chown
The basics work, but now I'm thinking about how this will affect existing workloads. What I've written currently chown's every bind mount to the user the task will run as. I'm wondering if I should do nothing if the user is running as root inside the container? I don't touch permissions of the rootfs.
Vito had mentioned there may be issues with volumes storing git repos. I looked into this and I don't think it'll be an issue. Git doesn't track file ownership at all.
I guess the main concern I have is: are there cases where we shouldn't chown a volume at all? Vito's comment here is my main concern:
Doing the recursive chown sounds kind of problematic and error prone. 😕 What if the user wanted some of the files to keep their original owner? Do we only chown from root? What if the inputs came from a previous step that was non-root and also not the current user (or UID)? Maybe it's OK as long as they're o+r or whatever is necessary? (Is that not an option generally?)
Sadly no one really engaged with that question. Most comments are discussing workarounds.
So engaging that question, the first thing that comes to mind is volumes representing container images, in any format (rootfs, oci). Container images usually have a mix of ownership across different files and folders. Blindly chown'ing them could break things when users try later using the images.
For example, here's the /etc/passwd for chainguard/wolfi-base:
Lots of users! Looking through the image, I can find various folders that are owned by users in this image.
Maybe we only chown files owned by root? That feels like a hacky solution though. And what happens when one task runs as nonroot, and then another task that takes an output from the first runs as another user or root? How do we know which files to chown now!?
I was curious how this works in Docker. I initially did the following on macOS, so Docker is running containers in a linux VM.
docker run -it --volume .:/tmp/src --user nonroot chainguard/wolfi-base sh
/ # ls -l /tmp
total 0
drwxr-xr-x 79 nonroot nonroot 2528 Jun 5 20:14 src
/ # mount | grep src
/run/host_mark/private on /tmp/src type fakeowner (rw,nosuid,nodev,relatime,fakeowner)
The mount is type fakeowner!? I have no clue what that is. Asking an LLM tells me it might be some custom thing Docker uses that makes it look like files at a mount are owned by the user currently looking at them without actually modifying the underlying file ownership at all. I can't verify this though.
/* * Copyright(C) 2022 Docker, Inc. * * Implementation based on shiftfs.c by James Bottomley, Seth Forshee and Christian Brauner*/
...
MODULE_ALIAS_FS("fakeowner");
MODULE_AUTHOR("Frédéric Dalleau <[email protected]>");
MODULE_AUTHOR("Piotr Stankiewicz <[email protected]>");
MODULE_DESCRIPTION("Implement file ownership using extended attributes. Based on shiftfs.");
MODULE_LICENSE("GPL v2");
We're in some really niche territory now!
Anyways, Docker uses this fakeowner module on Docker Desktop for macOS, and doesn't look like the code is readily available for us to use. It would also add an extra step when setting up workers "btw install this kernel module".
When running the same command on a Linux machine with Docker installed, the behaviour is different:
$ sudo docker run -it --volume .:/tmp/src --user nonroot chainguard/wolfi-base sh
/ $ ls -l /tmp
total 4
drwxr-xr-x 40 1000 1000 4096 Apr 21 2024 src
It's still owned by the user on the host system, which is UID 1000 for my machine.
Checking the mount setup in the container:
/ # mount | grep src
/dev/mapper/fedora-root on /tmp/src type xfs (rw,relatime,seclabel,inode64,logbufs=8,logbsize=32k,noquota)
No fakeowner here. So even on Linux Docker doesn't change the owner of bind mounts at all.
Looking at past comments in our own issue here, I'm surprised to see that Docker still has this issue open: moby/moby#2259
When a named volume is first mounted to a container, Podman automatically adjusts the ownership of the volume’s mount point during container initialization. This chown operation occurs under the following conditions:
The volume was not used yet (has NeedsChown set to true)
The volume is empty or has not been copied up yet
The volume is not managed by an external volume driver
The volume driver is not “image”
So even podman only does this under certain conditions and when chown=true is set for a volume. I've already adopted the last one of not modifying the owner of "image" volumes.
I'm thinking I should scope this down. Maybe we'll only chown volumes when user != root for the task. In all other cases we just leave the volume as-is. I think if you're root in a container and get a volume from a previous task step that ran as a non-root user, it won't affect your ability to do anything to that volume. And at that point I guess you can chown the volume to whatever you need it be?
I think I'll move ahead with that mind. I'm open to any thoughts people have about this and how it should be implemented.
I can see why no one ever picked this up. It's not that it's hard to implement, it's just hard to know if this setup will work for most people. Mostly worried abut people running into "permission denied" errors. It also feels like no matter what I do here I'll end up creating "footgun"-style problems that users could run into when passing volumes between steps that run under different users.
For example, when you tar files, depending if you run as root or not, ownership is or is not stored.
--no-same-owner
Extract files as yourself (default for ordinary users).
--same-owner
Try extracting files with the same ownership as exists in
the archive (default for superuser).
This could create "permission denied" errors way after the fact, when the pipeline has produced a tar artifact and now some other system is consuming it.
How likely is this to happen for someone's existing pipeline? That's what I'm worried about as I'm implementing this.
Maybe it's not a likely scenario for existing pipelines at all though? It seems running as anyone but root has not been very feasible for Concourse users. So maybe there are no workflows that this would break?
Another feature I thought might be useful, similar to podman's, is to add a chown option for each input/output/cache in a task. That puts the onus on the user to really think about file permissions. Still creates the same footguns though when passing volumes from one step to another that run under different users. Also makes tasks more verbose.
Don't think I'll go that route and will likely stick with my "automatically chown mounts" path that I'm on.
Activity
georgehaidar commentedon Jul 28, 2016
I am currently facing this problem as well and cannot, for example, run in
npm installin my node project (the task input) as a non-root user.bump a *bunch* of dependencies
endzyme commentedon Sep 1, 2016
+1 having the same problem
jpf91 commentedon Dec 18, 2016
Outputs as well, unfortunately. So it's not possible to generate outputs either.
miromode commentedon Feb 7, 2017
+1 for us as well - with all the root escape bugs docker has had up to very recently, I think this is extra important
ashb commentedon Feb 17, 2017
@miromode the root-escape bugs in docker might not affect Concouse as it uses it's own container runtime (caled "garden") to run containers, not docker, so there's a chance that the same bugs won't exist here. (Or they could share the same code from libcontainer and might be vulnerable. I don't know at either way)
wrl commentedon Mar 30, 2017
This is a hard requirement for building OpenWRT as well. We can hack around it by wrapping commands with
subut it's a hack.duncanatkinson commentedon Jun 8, 2017
I have hit this issue trying to use gradle image to build a gradle project, can work around it by specifying root, but I don't like being forced to do so. I think this is a bug, you have different behaviour when running gradle via docker
docker run --rm -v "$PWD":/project -w /project --name gradle gradle:alpine gradle <gradle-task>This is not consistent.
36 remaining items
fixes user permissions
arut-s2 commentedon Nov 10, 2025
Any progress on this?
taylorsilva commentedon Nov 11, 2025
Nope, no progress on this. Anyone is free to pick this up and work on it. I'll happily review any PR improving this.
I haven't dug into this at all so no suggestions for implementation. It'd be nice if this can be fully resolved within baggageclaim, but I think we'll need the runtime to fetch the user info for us.
Vito's two comments are relevant:
#403 (comment)
#403 (comment)
taylorsilva commentedon Jun 6, 2026
I've started working on this and have a WIP branch here: master...403-chown
The basics work, but now I'm thinking about how this will affect existing workloads. What I've written currently
chown's every bind mount to the user the task will run as. I'm wondering if I should do nothing if the user is running asrootinside the container? I don't touch permissions of the rootfs.Vito had mentioned there may be issues with volumes storing git repos. I looked into this and I don't think it'll be an issue. Git doesn't track file ownership at all.
I guess the main concern I have is: are there cases where we shouldn't
chowna volume at all? Vito's comment here is my main concern:Sadly no one really engaged with that question. Most comments are discussing workarounds.
So engaging that question, the first thing that comes to mind is volumes representing container images, in any format (rootfs, oci). Container images usually have a mix of ownership across different files and folders. Blindly
chown'ing them could break things when users try later using the images.For example, here's the
/etc/passwdforchainguard/wolfi-base:Lots of users! Looking through the image, I can find various folders that are owned by users in this image.
Maybe we only
chownfiles owned byroot? That feels like a hacky solution though. And what happens when one task runs as nonroot, and then another task that takes an output from the first runs as another user orroot? How do we know which files to chown now!?I was curious how this works in Docker. I initially did the following on macOS, so Docker is running containers in a linux VM.
The mount is type
fakeowner!? I have no clue what that is. Asking an LLM tells me it might be some custom thing Docker uses that makes it look like files at a mount are owned by the user currently looking at them without actually modifying the underlying file ownership at all. I can't verify this though.Searching for
fakeowneroddly yields very little results. I found this issue: docker/for-mac#6622which states it's a kernel module developed by some folks at Canonical. No clue why it's so hard to find this thing. Going back to my LLM, even it thinks it's not a real thing!
Digging into that Docker image from that issue, it looks like this is a fork of shiftfs maintained internally at Docker: https://aur.archlinux.org/packages/shiftfs
We're in some really niche territory now!
Anyways, Docker uses this
fakeownermodule on Docker Desktop for macOS, and doesn't look like the code is readily available for us to use. It would also add an extra step when setting up workers "btw install this kernel module".When running the same command on a Linux machine with Docker installed, the behaviour is different:
It's still owned by the user on the host system, which is UID 1000 for my machine.
Checking the mount setup in the container:
No
fakeownerhere. So even on Linux Docker doesn't change the owner of bind mounts at all.Looking at past comments in our own issue here, I'm surprised to see that Docker still has this issue open: moby/moby#2259
Users in that issue report Podman behaving differently though. Looks like default behaviour is the same, to not chown volumes mounted in a container. Podman does have an option
chown=truefor most mount types.Ah they go into a bit more detail here: https://docs.podman.io/en/latest/markdown/podman-run.1.html ("Chowning Volume Mounts")
So even podman only does this under certain conditions and when
chown=trueis set for a volume. I've already adopted the last one of not modifying the owner of "image" volumes.I'm thinking I should scope this down. Maybe we'll only chown volumes when
user != rootfor the task. In all other cases we just leave the volume as-is. I think if you'rerootin a container and get a volume from a previous task step that ran as a non-root user, it won't affect your ability to do anything to that volume. And at that point I guess you can chown the volume to whatever you need it be?I think I'll move ahead with that mind. I'm open to any thoughts people have about this and how it should be implemented.
taylorsilva commentedon Jun 8, 2026
I can see why no one ever picked this up. It's not that it's hard to implement, it's just hard to know if this setup will work for most people. Mostly worried abut people running into "permission denied" errors. It also feels like no matter what I do here I'll end up creating "footgun"-style problems that users could run into when passing volumes between steps that run under different users.
For example, when you
tarfiles, depending if you run asrootor not, ownership is or is not stored.From
man tar:This could create "permission denied" errors way after the fact, when the pipeline has produced a tar artifact and now some other system is consuming it.
How likely is this to happen for someone's existing pipeline? That's what I'm worried about as I'm implementing this.
Maybe it's not a likely scenario for existing pipelines at all though? It seems running as anyone but
roothas not been very feasible for Concourse users. So maybe there are no workflows that this would break?Another feature I thought might be useful, similar to podman's, is to add a
chownoption for each input/output/cache in a task. That puts the onus on the user to really think about file permissions. Still creates the same footguns though when passing volumes from one step to another that run under different users. Also makes tasks more verbose.Don't think I'll go that route and will likely stick with my "automatically chown mounts" path that I'm on.