Created
March 12, 2021 13:55
-
-
Save andgineer/8c956c27706a4ed85d4a32ebbe99992c to your computer and use it in GitHub Desktop.
Show port number of docker containers with specific name
This file contains hidden or 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
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