首页 修改docker容器启动时执行的命令

修改docker容器启动时执行的命令

举报
开通vip

修改docker容器启动时执行的命令     修改docker容器启动时执行的命令                  docker容器时指定了command,后期要修改可通过修改对应容器的config.v2.json来配置importos,json#####################################################################################Optionsthatmustbeconfigured#dockercontainername#Thedatatypeisstring,e...

修改docker容器启动时执行的命令
     修改docker容器启动时执行的命令                  docker容器时指定了command,后期要修改可通过修改对应容器的config.v2.json来配置importos,json#####################################################################################Optionsthatmustbeconfigured#dockercontainername#Thedatatypeisstring,example:#name='TestModExec'name='TestModExec'#Thecommandtoexecutewhenthedockercontainerstarts#Thedatatypeisstring,example:#command=u'/usr/bin/tail'#args=[u'-f',u'/dev/null']command=u'/usr/local/bin/python'args=[u'/codes/TestModExec/test.py']#####################################################################################Thefollowingpartsshouldnotbechangedatwill!!!!!!!!!!!!##getdockercontaineridresult=os.popen("dockerps--no-trunc|grep%s"%name)res=result.read()ifres:id_arr=res.split('')iflen(id_arr)>2:container_id=id_arr[0]ifcontainer_id:#formatconfig.v2.jsonpathconfig_path="/var/lib/docker/containers/%s/config.v2.json"%container_idifos.path.exists(config_path):withopen(config_path,'r')asfr:config=json.loads(fr.read())ifconfig:#stopdockerserviceos.system("systemctlstopdocker.socket")os.system("systemctlstopdocker")#modfiyconfigconfig[u'Path']=commandconfig[u'Args']=argsconfig[u'Config'][u'Cmd']=[command]+args#writetoconfigfilewithopen(config_path,'w')asfw:fw.write(json.dumps(config))#startdockerserviceos.system("systemctlstartdocker")#####################################################################################END -全文完-
本文档为【修改docker容器启动时执行的命令】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
资教之佳
暂无简介~
格式:doc
大小:27KB
软件:Word
页数:5
分类:互联网
上传时间:2023-06-27
浏览量:44