Menu Close

Docker – List of ports in docker container

We will help you to understand how to get list of ports in docker container. For this, we use “docker port” command.

docker port” command lists exposed ports in docker container.

Command:

docker port container_name_1

How docker port command works ?

  • docker port command query to docker engine to give list of exposed ports in given docker container.

Example:

% docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fa4c63f69001 redis:latest “docker-entrypoint.s…” 8 seconds ago Up 7 seconds 0.0.0.0:8001->6379/tcp, 0.0.0.0:8002->6379/tcp, 0.0.0.0:8003->6379/tcp redis-1
243dcda1066c redis:latest “docker-entrypoint.s…” About a minute ago Up About a minute 0.0.0.0:8000->6379/tcp redis

There are three ports attached to redis-1 container which are given below:

  • 0.0.0.0:8001->6379/tcp
  • 0.0.0.0:8002->6379/tcp
  • 0.0.0.0:8003->6379/tcp
% docker port redis-1

Output: 
% 
6379/tcp -> 0.0.0.0:8003
6379/tcp -> 0.0.0.0:8002
6379/tcp -> 0.0.0.0:8001

List down all the host ports connect to container port.

% docker port redis-1 6379/tcp

Output:
%
0.0.0.0:8003
0.0.0.0:8002
0.0.0.0:8001

To learn more about docker, Pls click given below link

https://techieindoor.com/category/docker/

References:

https://en.wikipedia.org/wiki/Docker_(software)

Posted in docker

Leave a Reply

Your email address will not be published. Required fields are marked *