There is no problem with the Dockerfile configuration, why does an error occur when executing the ENTRYPOINT command? The container exited as soon as it started. I checked a lot of information and thought about it for a long time before I found the reason. run.sh is copied to the container by the COPY instruction. However, the local machine is Windows, and the default line break character is \n, so it cannot be executed after being copied. The solution is simple, just switch the file format to LF. Supplementary knowledge: When starting a container in docker, the if command in the sh script called by CMD reports an unexpected symbol if[[. Solution Recently, I wrote an image through Dockerfile. The sh script (start.sh) was called in CMD to start the container. When it was started through docker run, the startup failed. I performed docker logs container ID and found that the error was: Unexpected symbol if [[ I successfully executed start.sh directly in the external Linux system. I entered the container through docker exec and called start.sh in the container without any errors. All the programs that needed to be started in the command were successfully started. There is no problem in executing the script directly, but an error occurs through docker run, which is puzzling. The error code segment in start.sh is as follows if [[ -e /home/dc/testnn-aaa.zip ]];then rm -rf /home/testnn-aaa unzip -q -o -d /home testnn-aaa.zip echo "unzip zip finished" else echo "dc zip not exist" fi After checking and comparing, because my start.sh also has an if statement before the error statement, but no error is reported, I found that the difference between the two places is that the first if uses a single []. If the code is changed to [], it will succeed. The modification is as follows:
The above article on solving the problem of docker CMD/ENTRYPOINT executing sh script: not found/run.sh: is all the content that the editor shared with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Vue interpretation of responsive principle source code analysis
>>: HTML is actually the application of learning several important tags
<br />Conditional comments are a feature uni...
After a lot of trouble, I finally figured out the...
How to write configuration files and use MyBatis ...
Table of contents Preface Centering inline elemen...
INSERT INTO hk_test(username, passwd) VALUES (...
CSS Sprite, also known as CSS Sprite, is an image...
As Web developers, although we are not profession...
In the process of making web pages, we often use f...
html , address , blockquote , body , dd , div , d...
Save the following code as the default homepage fi...
①. How to use the alias (CNAME) record: In the do...
MySQL batch insert problem When developing a proj...
Copy code The code is as follows: <hr style=&q...
Newer Linux distributions no longer have the rc.l...
(1) Server configuration: [root@localhost ~]# cd ...