What is the best way to find out in which environment the bash script is running (on the host machine or in a docker image)?
My bash script:
#!/bin/bash
function PKG_ABSENT { return `which "$1" 2>/dev/null | grep -cm1 "$1"`; }
if ! PKG_ABSENT "docker"; then
# Docker package is installed
echo "running in the host machine"
else
# Docker package is not installed
echo "running in a Docker image"
fi
Any Ideas?