7

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 ?

2 Answers 2

9

The problem is with your interpreter: sh Try exec form: ENTRYPOINT ["/bin/bash", "-c", "./docker-entrypoint.sh"]

Sign up to request clarification or add additional context in comments.

3 Comments

Since this was the solution, could you please convert this from a comment into an answer?
I beg your pardon.I am new here so I really do not understand what are you suggesting. This was the answer from me, not a comment. Something more I need to do ?
You wrote a comment as the answer. The comment ended up solving it. If you could rephrase the answer as a declaratory solution instead of an interrogative comment, then it could not be flagged as "not an answer", which it is susceptible to at the moment. I would suggest instead of speculating and asking in the answer, write it with conviction since you know you are right.
3

You use sh:

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

But in your entrypoint file you use bash:

#! /bin/bash

You have to choose

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.