To execute a shell command in Docker, you need to add sh -c before the command, for example: docker run ubuntu sh -c 'cat /data/a.txt > b.txt' Otherwise, the instruction cannot be parsed normally. Supplement: [Docker application] Execute the specified script in docker (run springboot application under docker) 【Docker application】 Execute the specified script in docker Here is an example of executing a spring boot application: 1. Create an image file (template) to execute the sh scriptDockfile FROM vertigomedia/ubuntu-jdk8 RUN touch /root/app_start.sh RUN echo "#!/bin/bash" > /root/app_start.sh RUN echo "echo 111" >> /root/app_start.sh RUN chmod a+x /root/app_start.sh ENV TZ 'Asia/Shanghai' ENV APP_FILE /root/app_start.sh EXPOSE 8889 CMD $APP_FILE #ENTRYPOINT ["/bin/sh", "-c", "$APP_FILE"] 2. Create a script file (script to be executed in the container)container.sh #!/bin/bash echo "test xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" java -jar -Xms500m -Xmx500m -Dspring.profiles.active=test-docker-1 /root/app.jar 3. Create a startup script (here is just the startup command)docker run -itd \ --name test_container \ --hostname test_container \ --net test_net --ip 170.170.1.199 \ --volume /root/container.sh:/root/app_start.sh \ --volume /opt/test-1.0.0-SNAPSHOT.jar:/root/app.jar \ --privileged=true \ test:123 /bin/bash -c 'sh /root/app_start.sh' The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
<<: Introduction to the use of MySQL source command
>>: CSS animation property usage and example code (transition/transform/animation)
When using MYSQL, triggers are often used, but so...
The effect to be achieved is: fixed zoom in twice...
A common suggestion is to create indexes for WHER...
There are very complex HTML structures in web pag...
Personal implementation screenshots: Install: npm...
css3 background image related Compatibility: IE9+...
1. On a networked machine, use the default centos...
This article example shares the specific code for...
Table of contents Vue.js 1. Register global guard...
Failure Scenario When calling JDBC to insert emoj...
I recently bought the cheapest Tencent cloud serv...
Table of contents Introduction and Demo API: Cont...
This article mainly introduces the sample code of...
Question 1: How do you instruct the browser to dis...
1. Install mysql Run the following command to upd...