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 IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
fa4c63f69001redis:latest“docker-entrypoint.s…”8 seconds agoUp 7 seconds0.0.0.0:8001->6379/tcp, 0.0.0.0:8002->6379/tcp, 0.0.0.0:8003->6379/tcpredis-1
243dcda1066credis:latest“docker-entrypoint.s…”About a minute agoUp About a minute0.0.0.0:8000->6379/tcpredis

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://www.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.

Contact Us