#!/bin/bash a=`docker ps|awk 'NR>1{print $1}'` FORMAT="%-12s , %-12s , %-12s " printf $FORMAT 容器ID IMAGE IPADDRESS for i in $a do IMAGE=`docker ps|grep $i|awk '{print $2}'` IP=`docker inspect $i|grep -i ipaddr|tail -1|awk -F" '{print $4}'` printf $FORMAT $i $IMAGE $IP done>docker_list.csv sz docker_list.csv