-1

How to know whether a terminal runs on a virtual machine or a container like Docker? Curious to find it.

1
  • Where? When? How? What is the circumstance you are trying to understand this within? Nov 13, 2020 at 3:16

1 Answer 1

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .