Skip to content

Instantly share code, notes, and snippets.

@andgineer
Created March 12, 2021 13:55
Show Gist options
  • Save andgineer/8c956c27706a4ed85d4a32ebbe99992c to your computer and use it in GitHub Desktop.
Save andgineer/8c956c27706a4ed85d4a32ebbe99992c to your computer and use it in GitHub Desktop.
Show port number of docker containers with specific name
for container_id in $(docker ps --filter "name=<ContainerName>" --quiet); do
docker inspect --format='{{(index (index .NetworkSettings.Ports "<PostNumber>/tcp") 0).HostPort}}' $container_id
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment