• docker 容器扩盘


    docker:/root/sbin# cat add_fs.sh 
    #!/bin/bash
    #This script is dynamic modify docker container disk
    #Author Deng Lei
    if [ -z $1 ] || [ -z $2 ]; then
        echo "Usage: container_name increase_capacity"
        echo "Example: I want increase 11G to test"
        echo "The command is:   sh `basename $0` test 11"
        exit 1
                                                                                                                                                            fi
    if [ `docker inspect $1 &>>/dev/null &&  echo 0 || echo 1` -eq 1 ];then
        echo "The container $1 is no exist!"
        exit 1
    fi
    container_id=`docker inspect -f '{{ .Id }}' $1`
    now_disk=`dmsetup table /dev/mapper/docker-*-$container_id|awk '{print $2}'`
    disk=$(($2*1024*1024*1024/512))
    if [ $disk -lt $now_disk ];then
        echo "I can't shink container $1 from $(($now_disk*512/1024/1024/1024))G to ${2}G!I only modify contanier increase disk!"
        exit 1
    fi
    dmsetup table /dev/mapper/docker-*-$container_id|sed "s/0 [0-9]* thin/0 $disk thin/"|dmsetup load /dev/mapper/docker-*-$container_id
    dmsetup resume /dev/mapper/docker-*-$container_id
    resize2fs /dev/mapper/docker-*-$container_id
    if [ $? -eq 0 ];then
        echo "dynamic container $1 disk to ${2}G is success!"
    else
        echo "dynamic container $1 disk to ${2}G is fail!"
    fi
    docker:/root/sbin# sh ./add_fs.sh d460fd1a2b32 50

  • 相关阅读:
    es的多种term查询
    es的批量导入
    可重入锁
    常见的字段类型
    es中的分词
    搜索的简单使用
    application.properties中的list配置
    mysql中的concat的几个函数使用
    文档的增删改查
    Mxnet学习笔记(3)--自定义Op
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200280.html
Copyright © 2020-2023  润新知