Is there any way to determine if a process (script) runs inside an lxc container (~ Docker runtime)? I know that some programs are able to detect whether they run inside a v
Docker creates a .dockerenv
file at the root of the directory tree inside container.
You can run this script to verify
#!/bin/bash
if [ -f /.dockerenv ]; then
echo "I'm inside matrix ;(";
else
echo "I'm living in real world!";
fi
MORE:
Ubuntu actually has a bash script: /bin/running-in-container
and it actually can return the type of container it has been invoked in. Might be helpful.
Don't know about other major distros though.