Skip to content

Instantly share code, notes, and snippets.

@kowalcj0
Created November 9, 2016 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kowalcj0/ca619ac17109f649f3131e4f161abf5d to your computer and use it in GitHub Desktop.
Save kowalcj0/ca619ac17109f649f3131e4f161abf5d to your computer and use it in GitHub Desktop.
Get the docker container ID from within it
#!/usr/bin/env bash
container_id=$(cat /proc/self/cgroup | grep -o "docker.*" | head -n 1 | cut -d/ -f 2)
echo ${container_id}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment