在dockerfile中给指定文件添加多行,注意echo后面的"$"符号
[root@master01 ovn-node]# cat dockerfile FROM ovn-node:2.11.2# sed 删除指定行RUN sed -i '53d' /root/start-ovs.sh# 用echo添加多行内容RUN echo $'OVERLAY_ENDPOINT=`hostname -i`/n/ovs-vsctl set open . external-ids:ovn-encap-ip=${OVERLAY_ENDPOINT}/n//n/# create a bridge , then mapping outside port/n/ovs-vsctl add-br br-ex/n/ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=phyNet:br-ex/n//n/# add nicovs-vsctl add-port br-ex ${OVN_PHYNET_NIC}/n//n/tail -f /var/log/openvswitch/ovs-vswitchd.log/n'/>> /root/start-ovs.shCMD ["/bin/bash","/root/start-ovs.sh"]
结果: 注意多行文本中"#" 注释行,并没有输入到指定文件中
[root@master01 ovn-node]# cat /root/start-ovs.sh# Set remote ovn-sb for ovn-controller to connect toovs-vsctl set open . external-ids:ovn-remote=tcp:${OVN_SB_SERVICE_HOST}:${OVN_SB_SERVICE_PORT}ovs-vsctl set open . external-ids:ovn-encap-type=geneveOVERLAY_ENDPOINT=`hostname -i`ovs-vsctl set open . external-ids:ovn-encap-ip=${OVERLAY_ENDPOINT}ovs-vsctl add-br br-exovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=phyNet:br-exovs-vsctl add-port br-ex ${OVN_PHYNET_NIC}tail -f /var/log/openvswitch/ovs-vswitchd.log
以上所述是小编给大家介绍的dockerfile echo指定文件多行文本的方法实现,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对17站长网的支持!