DEV Community

Cover image for Get container ID from within container
Adam K Dean
Adam K Dean

Posted on

Get container ID from within container

To get the container ID from within a container, use this:

$ cat /proc/self/cgroup | grep "docker" | sed s/\\//\\n/g | tail -1
Enter fullscreen mode Exit fullscreen mode

I'll probably stick it in an npm module at some point.

Top comments (0)