I have some docker image. In my example it is called sample_nginx
:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sample_nginx latest 4b34f8307839 34 hours ago 231.6 MB
I can run it docker run sample_nginx
and in the colomn "PORTS" I can see what ports are exposed from that image:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
650d7a9fe46e sample_nginx:latest "/bin/sh -c 'nginx - 3 minutes ago Up 3 minutes 80/tcp sleepy_mclean
Is it possible to find out what ports are exposed from the image without running it?
You can use docker inspect
on an image to find this (and a variety of other interesting things):
$ docker inspect redis:latest
The above command will give you a significant amount of detail. You can alternately pass a format argument to return just what you're looking for, as below.
$ docker inspect --format='{{.Config.ExposedPorts}}' redis:latest
map[6379/tcp:map[]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With