Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list exposed port of all containers?

We have lots of containers started using Rancher with each container exposing multiple ports. Since we started the containers with Rancher, no port is exposed to the host by default.

$ docker container ls  

shows no exposed ports for containers started by rancher. Rancher CLI rancheris not installed.

How to list ports which are exposed within the rancher network? Is this possible using the docker command? Or do I need rancher?

like image 599
WeSee Avatar asked Apr 13 '18 16:04

WeSee


People also ask

How do I know if my Docker port is exposed?

Exposed ports are visible when you list your containers with docker ps . They'll show up in the PORTS column, even though they won't actually be accessible outside the container. This gives you a simple way of checking which ports the software inside a container is listening on.

How do I know which ports are exposed?

A more reliable way to check which ports are listening on the network is to use a port scanner such as nmap. This command returns no output. This indicates that while the port is in the reserved range (meaning 0 through 1023) and requires root access to open, it is not associated with a known service.

How can you obtain the port exposed by the container?

You can expose a port through your Dockerfile or use --expose and then publish it with the -P flag. This will bind the exposed port to your Docker host on a random port (verified by running docker container ls ). You can expose a port through your Dockerfile or use --expose and then publish it with the -p 80:80 flag.

How do I find my container port?

The left-hand side of the port number mapping is the Docker host port to map to and the right-hand side is the Docker container port number. When you open the browser and navigate to the Docker host on port 8080, you will see Jenkins up and running.


1 Answers

for show ports on one host you can try to use

docker container ls --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}" -a 

more examples you can find here docker-container-ls by manpages.ubuntu.com

like image 148
Sergey Avatar answered Sep 22 '22 15:09

Sergey