zoukankan      html  css  js  c++  java
  • docker clean images

    docker ps | grep portal | awk '{print $2}' | cut -d ":" -f3

    used=`docker ps | grep portal | awk '{print $2}' | cut -d ":" -f3`
    echo $used
    docker images | grep portal | grep -v $used | awk '{print $3}'
    处理过的cleanImages.sh
     1 #!/bin/bash
     2 i=0
     3 using=`docker ps | grep portal | awk '{print $2}' | cut -d ":" -f3`
     4 echo "using image is $using"
     5 for line in `docker images | grep portal | grep -v $using | awk '{print $3}'`
     6 do
     7     noUsed[${i}]=$line
     8     let i=${i}+1
     9 done
    10 for imageId in ${noUsed[*]}
    11 do
    12     docker rmi $imageId
    13     echo "$imageId is deleted"
    14 done
    15 echo "clean finish"
    shell 将命令返回结果 赋给一个变量,用的是符号`,赋值时等号左右不能有空格,变量名需要遵循用户变量规范
     
    使用用户变量无需事先声明,同时变量名的命名须遵循如下规则:
    1). 首个字符必须为字母(a-z,A-Z);
    2). 中间不能有空格,可以使用下划线(_) ;
    3). 不能使用标点符号 ;
    4). 不能使用bash里的关键字(可用help命令查看保留关键字)
     
    shell中管道两侧的命令是分别在两个子shell中执行的,而子shell中定义的变量在父shell中是不可见的
    docker rmi `docker images| grep process | awk '{print $3}'`
  • 相关阅读:
    Linux 技巧:让进程在后台可靠运行的几种方法
    caffe 中的的参数
    adaboost+svm
    [caffe] 数据制作和训练
    [caffe] 安装及使用注意
    [算法] POJ1007
    vim 配置
    [触觉]数据集
    [theano]安装-python theano cuda
    博客迁移
  • 原文地址:https://www.cnblogs.com/xxdfly/p/6694734.html
Copyright © 2011-2022 走看看