Created
April 12, 2019 21:01
-
-
Save alanhoyle/767ea131401b6d151fd05d314248019d to your computer and use it in GitHub Desktop.
Simple script to check if the current shell is running in a linux container
This file contains 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
#! /usr/bin/env sh | |
if [[ "$OSTYPE" == "linux-gnu" ]] ; then | |
if grep -q docker /proc/1/cgroup || test -e /.dockerenv ; then | |
echo DOCKER ; | |
elif grep -q lxc /proc/1/cgroup ; then | |
echo LXC ; | |
elif test -z ${SINGULARITY_CONTAINER+x} ; then | |
echo no_container ; | |
else | |
echo SINGUARITY ; | |
fi | |
else | |
echo 'unsupported OS: $OSTYPE != "linux-gnu"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment