Reputation: 125
On running docker ps command I get all the processes that are running. I have deployed MongoDB instances onto docker containers. And on giving docker ps | grep mongo
it shows all the mongodb instances that are running. Refer the picture for better understanding
Now I have to display the port details and it is little ambiguous, the end result should be 2040
.
Though I have come up with something which indeed gives the correct output but I am hoping for a short and more efficient way to get the port details.
This is how I am getting the o/p currently
docker ps | grep mongo | awk '{print $10}' | awk -F ":" '{print $2}'| cut -d '-' -f 1
Upvotes: 0
Views: 1514
Reputation: 180
do this,
docker ps|grep mongo|awk '{print $1}'|xargs docker inspect --format="{{json .NetworkSettings.Ports}}"
Upvotes: 1