Dockerfile echo specifies the method of implementing multiple lines of text in the specified file

Dockerfile echo specifies the method of implementing multiple lines of text in the specified file

Add multiple lines to the specified file in Dockerfile, pay attention to the "$" symbol after echo

[root@master01 ovn-node]# cat dockerfile 
FROM ovn-node:2.11.2

# sed deletes the specified line RUN sed -i '53d' /root/start-ovs.sh

# Use echo to add multiple lines of content 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 nic
ovs-vsctl add-port br-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"]

Result: Note that the "#" comment line in the multi-line text is not entered into the specified file

[root@master01 ovn-node]# cat /root/start-ovs.sh
# Set remote ovn-sb for ovn-controller to connect to
ovs-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=geneve

OVERLAY_ENDPOINT=`hostname -i`
ovs-vsctl set open . external-ids:ovn-encap-ip=${OVERLAY_ENDPOINT}

ovs-vsctl add-br br-ex
ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=phyNet:br-ex

ovs-vsctl add-port br-ex ${OVN_PHYNET_NIC}

tail -f /var/log/openvswitch/ovs-vswitchd.log

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of the specific use of the ENV instruction in Dockerfile
  • Docker Basic Tutorial: Detailed Explanation of Dockerfile Syntax
  • Explanation of Dockerfile instructions and basic structure
  • Implementation of crawler Scrapy image created by dockerfile based on alpine
  • How to create your own image using Dockerfile
  • How to use Dockerfile to build images in Docker
  • How to use Dockerfile to create a mirror of the Java runtime environment
  • Summary of common commands in Dockerfile
  • Dockerfile text file usage example analysis

<<:  In-depth analysis of MySQL from deleting the database to running away_Advanced (I) - Data Integrity

>>:  Detailed explanation of multi-version concurrency control of large objects in MySQL

Recommend

Native js to implement drop-down menu

Drop-down menus are also very common in real life...

How to make a div height adaptive to the browser height

This old question has troubled countless front-end...

VUE+Express+MongoDB front-end and back-end separation to realize a note wall

I plan to realize a series of sticky note walls. ...

Detailed explanation of CSS animation attribute keyframes

How long has it been since I updated my column? H...

Several methods of implementing carousel images in JS

Carousel The main idea is: In the large container...

Advertising skills in the Baidu Union environment (graphic tutorial)

Recently, students from the User Experience Team o...

vue-admin-template dynamic routing implementation example

Provide login and obtain user information data in...

js to create a carousel effect

I think the carousel is a relatively important po...

Summary of considerations for writing web front-end code

1. It is best to add a sentence like this before t...

Summary of the differences between count(*), count(1) and count(col) in MySQL

Preface The count function is used to count the r...

How to use Element in React project

This is my first time using the element framework...

JS interview question: Can forEach jump out of the loop?

When I was asked this question, I was ignorant an...

How to configure jdk environment under Linux

1. Go to the official website to download the jdk...

Mysql cannot select non-aggregate columns

1. Introduction I recently upgraded my blog and a...

How to use VirtualBox to simulate a Linux cluster

1. Set up HOST on the host Macbook The previous d...