I am currently using a Dockerfile to run 2 shell scripts when building a Docker image. If I don’t run either shell script while building the image, but instead start up a container and then run the first shell script, it will ask for two inputs. If I specify the first one as ‘root’ and the second as ‘/root’, then the various files installed by the first shell script are exactly where the second shell script wants them to be.
How can I write my Dockerfile so that if I attempt to run the first shell script using:
RUN instal_script1.sh
It will give ‘root’ as the response to the first query and ‘/root’ as the response to the second query?
2
Answers
Try passing the arguments (separated by
n
) to the script using a pipe, like thisTo automatically run the script instal_script1.sh in the Dockerfile with predefined responses to the prompts, you can use the "echo" command in combination with pipes "|"