简体   繁体   中英

Docker running script in entrypoint

In Dockerfile I have defined an entrypoint :

ENTRYPOINT ["sh", "./docker-entrypoint.sh"]

In the docker-entrypoint.sh , I want to create a file ( file.json ) from the template.json , which is nothing but replaces some environment variables with actual values.

#! /bin/bash

eval "echo \"$(<template.json)\"" > file.json; npm start

Now, after getting in the container, I see file.json is empty. But if I execute the exact same command in the bash prompt inside the container, it works, and I see the required contents in file.json .

Why is this behaviour ?

问题在于你的解释器: sh尝试exec形式: ENTRYPOINT ["/bin/bash", "-c", "./docker-entrypoint.sh"]

You use sh :

ENTRYPOINT ["sh", "./docker-entrypoint.sh"]

But in your entrypoint file you use bash :

#! /bin/bash

You have to choose

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM