docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f56084659b2a nginx:alpine "/docker-entrypoint.…" 35 seconds ago Up 33 seconds 0.0.0.0:3456->3456/tcp, 0.0.0.0:38080->80/tcp xenodochial_perlman
what is the cmd to actually count num of ports from PORTS column in 1 line?
2
Answers
Ports in itself is a long string, even though it looks like a list. You can see that by using
{{ json . }}
or{{ json .Ports }}
.You can work around that by using the split function and then calling len on the resulting slice.
Furthermore, you can still show it in a table, but the column name for that
len
column will be a number. I have not found out yet how to rename columns with the table function. I did ask one time in the slack group, but didn’t get an answer to that.Using
inspect
: