Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find what ports are exposed from docker image?

Tags:

docker

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?

like image 668
bessarabov Avatar asked Oct 18 '14 20:10

bessarabov


1 Answers

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[]]
like image 82
Derek Slager Avatar answered Oct 03 '22 23:10

Derek Slager