首页 > 其他 > 详细

编辑 docker 容器内部文件

时间:2020-12-17 20:56:28      阅读:93      评论:0      收藏:0      [点我收藏+]

一个容器跑起来,有时候得修改内部的配置文件。但是容器内部的 shell 有时甚至连个 vi 都不带,笨方法,docker cp 出来,改完再放进去。你知道的问题还好改,如果是边调试连修改,就很烦人了。

于是,我就写了个函数。可以实现修改后多次直接上传。

效果图:

技术分享图片

 

进入容器查看文件是否修改成功

技术分享图片

 

代码很简单,不解释了。

function docker.open(){

    local container="$1"
    local infile="$2"
    local outfile=/tmp/`basename $infile`

    docker cp $container:$infile $outfile && gedit $outfile
    [ $? != 0 ] && return 1

    local update=""
    until [ "$update" == ‘exit‘ ]
    do
        read -p "更新?" update
        [ "$update" == ‘exit‘ ] && break
        docker cp $outfile $container:$infile

    done
    
}

  

 

编辑 docker 容器内部文件

原文:https://www.cnblogs.com/zbseoag/p/14151858.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!