Created
November 29, 2017 22:58
-
-
Save albertzak/6c28d9a76a536c810b0ca033dcd6bace to your computer and use it in GitHub Desktop.
Running Inside Container?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
is_container () { | |
cgroup_output=$(cat /proc/self/cgroup 2>&1) | |
echo "$cgroup_output" | grep -E '/docker/|/lxc/' > /dev/null | |
return $? | |
} | |
if is_container; then | |
echo "I'm trapped inside a container." | |
else | |
echo "Wohoo, I'm free!" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment