Skip to content

Instantly share code, notes, and snippets.

@jrumbut
Created April 13, 2016 16:34
Show Gist options
  • Save jrumbut/796c07a1330c02bb2804b42ae02b968c to your computer and use it in GitHub Desktop.
Save jrumbut/796c07a1330c02bb2804b42ae02b968c to your computer and use it in GitHub Desktop.
Helpful Docker function, gives you Hostname (often shortened container id), name, IP address, and port bindings for all running containers
#defines function for later use, put it in .bashrc or similar
#usage: docker-net
#output:
#bdc5fb58bc94 /adoring_euler 172.17.0.3 map[8888/tcp:[{ 8888}]]
#c7591aa275ff /hopeful_davinci 172.17.0.2 map[6006/tcp:[{ 32769}] 8888/tcp:[{ 80}]]
docker-net() {
docker inspect --format '{{ .Config.Hostname }} {{ .Name }} {{ .NetworkSettings.IPAddress }} {{ .HostConfig.PortBindings }}' $(docker ps -q);
}
@vsoch
Copy link

vsoch commented May 15, 2019

Thank you for this! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment