How provide nested mount of overlayfs
If you check dmesg output, you will see the kernel stating an attempt to exceed the max stacking depth:
overlayfs: maximum fs stacking depth exceeded
Indeed, the stacking depth is limited to 2, see the overlayfs dev branch:
- #define FILESYSTEM_MAX_STACK_DEPTH
- stacking depth check
If you want to go beyond this depth, you could try changing the constant and building your own kernel. However, bear in mind the risk of overflowing the stack (per the comments).
overlayfs inside docker container
Found something that worked! Mounting the workdir and upperdir as tmpfs does the trick for me.
Like so:
> mkdir /tmp/overlay
> mkdir /tmp/{low,merged}
> mount -t tmpfs tmpfs /tmp/overlay
> mkdir /tmp/overlay/{up,work}
> mount -t overlay overlay -o lowerdir=/tmp/low/,upperdir=/tmp/overlay/up/,workdir=/tmp/overlay/work/ /tmp/merged/
I'd still be interested in an explanation why creating an overlay w/o tmpfs fails within a docker container?
Can I mount docker host directory as copy on write/overlay?
Edit: Check @javabrett's comment:
Upvoted despite this solution having a sunset. See answer regarding overlay-upperdir-on-overlay being disabled on 4.8 kernels and newer.
See: https://stackoverflow.com/a/50917037/644504
This is what I do:
On the host:
Load the directory as read only.
docker run --privileged -v /path/on/host:/path/on/client-read-only:ro -it ubuntu /bin/bash
On the client:
On the client use OverlayFS over the read-only directory mounted from the host.
mount -t overlayfs none -o lowerdir=/path/on/client-read-only,upperdir=/path/on/client /path/on/client
Then use /path/on/client
to read/write the files.
Edit: if you have a 3.18+ kernel on your host, you may prefer using this on the client:
mount -t overlay overlay -o lowerdir=/path/on/client-read-only,upperdir=/path/on/client,workdir=/path/on/client-workdir /path/on/client
Which isn't overlayfs
. With overlayfs
I had an issue regarding being unable to use rm
. overlay
solved this problem for me.
Related Topics
How to Start/Restart/Stop Apache Server on Linux as Non-Root User
Find Command Find Directories That Were Created After a Certain Date Under Linux/Cygwin
Apache Proxypass Not Loading Resources
Executable Object Files and Virtual Memory
"Command Not Found" Piping a Variable to Cut When Output Stored in a Variable
Ssh Connection to Ubuntu Open Ssh-Server Requires Login on (Physical) Server via Password First
Remove Left and Right Square Brackets Using Sed/Bash
Requirement for Transport Stream Streaming Server
How to Change the Name of One Single Thread in Linux
How to Detect a Blank Column in a Page Using Imagemagick to Distinguish Two Column Papers
Shell Script Won't Recognize Heredoc Delimiter
Create a Sudo User in Script with No Prompt for Password, Change to User Without Interrupting Script
How to Install Asp on Linux Ubuntu Hardy
Split File into Multiple File Using Awk, But in Date Format
Print Differences of File1 to File2 Without Deleting Anything from File2
Using Ssh to Run a Cleartool Command with Agruments on Remote a Linux MAChine