What are the .dockerenv and .dockerinit files in the root of my container's filesystem? How are they used? Is there any documentation on these files?
root@18ceee4f9041:/# ls -al /
total 72
drwxr-xr-x. 21 root root 4096 Jan 4 20:45 .
drwxr-xr-x. 21 root root 4096 Jan 4 20:45 ..
-rwxr-xr-x. 1 root root 0 Jan 4 20:45 .dockerenv
-rwxr-xr-x. 1 root root 0 Jan 4 20:45 .dockerinit
Other people have asked similar questions, but I can find no answers:
- .dockerinit / .dockerenv (9/12/2015)
I'm asking because I'm working on a bug in my docker-executing tool called scuba. You can pass --user to docker run to set the UID of the process in a container, but it has no entry in /etc/passwd, so I was investigating options for creating the user during container startup.
(Cross-posted at Stack Overflow, where it may be closed.)
-uargument. You can read the implementation here. – zuazo Jan 05 '16 at 10:36/.dockerenvstill exists in every docker container. – ttimasdf Aug 17 '20 at 12:33/proc/1/cgroupdoesn't work for cgroups V2, and I need a way to know if I'm being run inside docker or not, these empty files are a very simple thing to solve that requirement. – GACy20 Feb 01 '22 at 16:40