Quick-Hit: Am I Inside A Docker Container?

If you don’t know, here’s an easy way to find out…

cat /proc/self/cgroup

If you see “/docker/{hash}” following one of the outputs then yes, yes you are. A non-Docker system looks like the following:

11:freezer:/
10:perf_event:/
9:pids:/user.slice
8:cpuset:/
7:memory:/user.slice
6:net_cls,net_prio:/
5:blkio:/user.slice
4:cpu,cpuacct:/user.slice
3:hugetlib:/
2:devices:/user.slice
1:name=systemd:/user.slice/{etc}

A Docker system looks like this:

11:freezer:/
10:perf_event:/
9:pids:/user.slice
8:cpuset:/
7:memory:/user.slice
6:net_cls,net_prio:/
5:blkio:/user.slice
4:cpu:/docker/{hash}
3:hugetlib:/
2:devices:/docker/{hash}
1:name=systemd:/user.slice/{etc}

Good hunting!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: