How to know whether a terminal runs on a virtual machine or a container like Docker? Curious to find it.
1 Answer
One way is to try finding information related to docker.
cat /proc/self/cgroup | grep -o -e "docker-.*.scope" | head -n 1 | sed "s/docker-\(.*\).scope/\\1/"
The above will return an ID if inside a docker container. More information about this command here
If it fails probably you're not inside a docker container.