sudo docker rmi $(sudo docker images -q -f dangling=true)
sudo docker rmi $(sudo docker images -q)
不带表头
sudo docker ps -a --format "{{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Status}}"
带有表头
docker ps -a --format "table {{.ID}}\t{{.Image}}\t{{.Names}}"
docker images --format "{{.Repository}}:{{.Tag}}"
docker inspect nginx | jq .[].Mounts
docker inspect 容器名字 | jq .[].Config.Env
docker inspect 容器名字 | jq .[].Config.Cmd
docker inspect 容器名字 | jq .[].HostConfig.NetworkMode
docker inspect 容器名字 | jq .[].HostConfig.Tmpfs
docker inspect nginx | jq .[0].LogPath
清空日志
logpath=`sudo docker nginx | jq .[0].LogPath | sed 's/\"//g'` && sudo sh -c 'echo "" > '${logpath}' '
docker save nginx | gzip > nginx.tgz
gunzip -c nginx.tgz | docker load
批量导入 tgz
for line in `ls *.tgz`; do gunzip -c $line | docker load ; done
for line in `docker ps -a --format "{{.Image}}"`;do echo `basename $line` ; done
for line in `docker ps -a --format "{{.Image}}"`;do docker save $line | gzip > `basename $line`.tgz ; done
for line in `docker ps -a --format "{{.Image}}"` ;do echo `basename $line`| tr -s ":" "-"; done
for line in $(docker ps -a --format "{{.Image}}");do docker save $line | gzip > $(echo $(basename $line)| tr -s ":" "-").tgz; done
cat images
hub.xxy.cn/yyy/ app-a 2.0.44.8_beta-df072a3 ccc-version
hub.xxy.cn/yyy/ app-b 2.0.44.8_beta-df072a3 ccc-version
for image in `grep -v '^\s*$' images|awk '{print $1,$2,$3}'|sed -s 's@/ @/@g'|sed -s 's@ @:@g'`; do docker pull $image;done;
images=`grep -v '^\s*$' images|awk '{print $1,$2,$3}'|sed -s 's@/ @/@g'|sed -s 's@ @:@g'`;for image in $images;do imageName=`echo $image | rev | cut -d'/' -f 1 | rev`; name=`echo $imageName | cut -d ':' -f1`; tag=`echo $imageName | cut -d ':' -f2`;docker save $image | gzip > $name-$tag.tgz ;done;
for line in `docker ps --format "{{.Names}}"`;do docker inspect $line > $line.json ; done
for line in `docker ps --format "{{.Names}}"`;do echo $line ;docker inspect $line | jq .[].Mounts | grep '/data/record'; done
一次性运行容器
docker run --rm -p 80:80 -ti --name test yimtune/nginx echo "hello"