While trying to set up a docker container I stumbled across something I don't know how to solve, understand or google.
I have a Dockerfile where I run a script. One layer of the Dockerfile is:
RUN cd /app/spinnaker-1.23.0.27-amd64 && \
printf 'y\nn\n' | sh install_spinnaker.sh
Basically I copied that line from some GitHub repo.
When I try to build this Dockerfile with docker build --tag=app .
it will run the install_spinnaker.sh
until the very end but then crash with:
[Y/n] $ The command '/bin/sh -c cd /app/spinnaker-1.23.0.27-amd64 && printf 'y\nn\n' | sh install_spinnaker.sh' returned a non-zero code: 1
On the other hand, when remove this line from the Dockerfile, build it, and then open a bash on the container with docker run -ti app bash
and inside the container then run the same command, i.e.
cd /app/spinnaker-1.23.0.27-amd64 && printf 'y\nn\n' | sh install_spinnaker.sh
it will just work.
Now, there are actually three [Y/n] questions. So printf 'y\nn\n' | sh install_spinnaker.sh
should not work, either in the dockerfile nor the interactive bash I guess?
So I tried with a few different ones. The following seemed most plausible to me:
RUN cd /app/spinnaker-1.23.0.27-amd64 && \
printf 'y\nn\nn\n' | sh install_spinnaker.sh
which I expected to work because there are three questions. But it doesn't work and I don't know why. On building the Dockerfile it gives the following at the end:
Installation complete.
Would you like to register the installed software?
[Y/n] $ error: process ID out of range
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.
For more details see ps(1).
The command '/bin/sh -c cd /app/spinnaker-1.23.0.27-amd64 && printf 'y\nn\nn\n' | sh install_spinnaker.sh' returned a non-zero code: 1
I don't see my mistake here. Please if you see anything obvious, let me know.
RUN sh -c 'cd ... && printf "y\n..." | sh ...'
work?/bin/sh -c
anyways. Thus with your suggestion the error I get is the same as above with theerror: process ID out of range.
and it sais now thatThe command '/bin/sh -c sh -c 'cd /app/spinnaker-1.23.0.27-amd64 && printf "y\nn\nn\n" | sh install_spinnaker.sh'' returned a non-zero code: 1
Again on the last question of the script.sed -i '50,101d' install_spinnaker.sh
and now it does what I want it to do. Thank you.