dockerfile echo指定文件多行文本的方法实现
在dockerfile中给指定文件添加多行,注意echo后面的"$"符号
[root@master01ovn-node]#catdockerfile FROMovn-node:2.11.2 #sed删除指定行 RUNsed-i'53d'/root/start-ovs.sh #用echo添加多行内容 RUNecho$'OVERLAY_ENDPOINT=`hostname-i`\n\ ovs-vsctlsetopen.external-ids:ovn-encap-ip=${OVERLAY_ENDPOINT}\n\ \n\ #createabridge,thenmappingoutsideport\n\ ovs-vsctladd-brbr-ex\n\ ovs-vsctlsetOpen_vSwitch.external-ids:ovn-bridge-mappings=phyNet:br-ex\n\ \n\ #addnic ovs-vsctladd-portbr-ex${OVN_PHYNET_NIC}\n\ \n\ tail-f/var/log/openvswitch/ovs-vswitchd.log\n'\ >>/root/start-ovs.sh CMD["/bin/bash","/root/start-ovs.sh"]
结果:注意多行文本中"#"注释行,并没有输入到指定文件中
[root@master01ovn-node]#cat/root/start-ovs.sh #Setremoteovn-sbforovn-controllertoconnectto ovs-vsctlsetopen.external-ids:ovn-remote=tcp:${OVN_SB_SERVICE_HOST}:${OVN_SB_SERVICE_PORT} ovs-vsctlsetopen.external-ids:ovn-encap-type=geneve OVERLAY_ENDPOINT=`hostname-i` ovs-vsctlsetopen.external-ids:ovn-encap-ip=${OVERLAY_ENDPOINT} ovs-vsctladd-brbr-ex ovs-vsctlsetOpen_vSwitch.external-ids:ovn-bridge-mappings=phyNet:br-ex ovs-vsctladd-portbr-ex${OVN_PHYNET_NIC} tail-f/var/log/openvswitch/ovs-vswitchd.log
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。