Created
December 8, 2016 13:58
-
-
Save nmarley/0ee3e2cf14dabfb868eb818b8b30e7e0 to your computer and use it in GitHub Desktop.
Docker — get container ID from within Docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bash-4.3# cat /proc/1/cpuset | |
/docker/13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e | |
bash-4.3# DOCKER_CID=$(cat /proc/1/cpuset | cut -c9-) | |
bash-4.3# echo $DOCKER_CID | |
13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e |
After most recent update of docker (on MacOS) it may be better to use:
awk -F/ '{ print $NF }' /proc/1/cpuset
$ cat /proc/1/cpuset
/docker-ce/docker/dfffffff5ac7468ef6117c44274bde16185fd9330f96561b1fffffffb16e05f8
Thanks, it helps a lot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or: