Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active August 29, 2015 14:01
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 tkuchiki/648bb941f8689f5b58a2 to your computer and use it in GitHub Desktop.
Save tkuchiki/648bb941f8689f5b58a2 to your computer and use it in GitHub Desktop.
docker memo

container id search by container name

$ docker ps -a | grep CONTAINER_NAME | cut -d ' ' -f 1
03b1407f8ba4

retrieve binding port

$ docker inspect --format='{{(index (index .NetworkSettings.Ports "22/tcp") 0).HostPort}}' 03b1407f8ba4
49159

$ docker port 03b1407f8ba4 22 | cut -d ':' -f 2
49159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment