Closed
Description
I've narrowed down a problem in an originally more involved setup. Consider the following Dockerfile:
# Dockerfile
FROM ubuntu:12.10
RUN apt-get install -y puppetmaster sudo
RUN rm -rf /etc/puppet
ADD puppet-config /etc/puppet
RUN chown -R puppet.puppet /etc/puppet
RUN chmod 755 /etc/puppet
When run with the following:
# make a dummy directory
mkdir puppet-config
echo "hi" >puppet-config/hello.txt
docker build -t dockbug .
echo "note the directory is owned by puppet with full read/write/execute privs"
docker run dockbug ls -al /etc/puppet
echo "but we get a permission error here"
docker run dockbug sudo -u puppet ls -al /etc/puppet
I see an unexpected permission error in the final command. This is with Docker 0.3.4 from the PPA on Ubuntu 13.04 with kernel 3.8.0-19-generic. Interestingly, if I remove the like "RUN rm -rf /etc/puppet" from the Dockerfile, I no longer see the permission error.
Activity
creack commentedon Jun 1, 2013
@jpetazzo can you take a look at this one?
jpetazzo commentedon Jun 11, 2013
This is a kind of bug in AUFS. When a directory has a given permission mask in a lower layer, the upper layers cannot have a broader mask. Well, they can, but the more restrictive permission mask will be enforced anyways.
The rationale is the following:
Multiple behaviors could be considered "acceptable" in this scenario:
My understanding is that the last solution should be used, but for some reason, AUFS doesn't behave correctly. It might be because the directory exists in a lower layer, then doesn't exist anymore (because of the rm), then exists again (because of the ADD).
I'm willing to take a guess: the logic that decides whether or not to do a whiteout is not exactly the same as the one looking up permissions; so the first one stops when /etc/puppet is marked as non-existent in the middle layer, while the latter goes bottom up.
Anyway!
As a workaround, you can
rm /etc/puppet/*
instead ofrm /etc/puppet
, and that will do the trick.shykes commentedon Aug 13, 2013
Labelling as aufs-related.
shykes commentedon Aug 13, 2013
Since this is documented aufs behavior, we can 1) close this as wontfix, 2) close + document the behavior in the docker docs, or 3) other?
shykes commentedon Aug 13, 2013
@jpetazzo what do you think?
jpetazzo commentedon Aug 13, 2013
Hmmm... What about a "KNOWN BUGS AND ISSUES" section in the documentation? /cc @metalivedev
metalivedev commentedon Oct 14, 2013
Ok, some discussion here: https://botbot.me/freenode/docker-dev/msg/6889335/
I'll look at how to provide the known issues in context, which implies that the docs need some place to describe the file system in use.
xaviershay commentedon Oct 15, 2013
This bit me.
metalivedev commentedon Oct 19, 2013
@xaviershay Could you give me the steps to reproduce the problem? I haven't been able to see an error with @astraw 's steps.
xaviershay commentedon Oct 19, 2013
Having trouble replicating again.
The shape of my setup was building an image on top of itself (which is potentially a terrible idea):
tianon commentedon Oct 19, 2013
That looks to me like you'd run into the AUFS 42 layer limit pretty quickly.
xaviershay commentedon Oct 19, 2013
Yeah that was the next bug I hit :)
Have since redone my process to always build off a single base image.
147 remaining items
[dist] Workaround an aufs bug
time to test whether but as per moby/moby#783 (comment) is fixed with…
KnowSky404 commentedon Aug 23, 2021
Thanks, it works for me!