2

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.

  • 3
    Does using RUN sh -c 'cd ... && printf "y\n..." | sh ...' work? – Kusalananda Jun 29 at 21:50
  • I tried it out, but it doesn't help. Actually I think RUN gets translated to /bin/sh -c anyways. Thus with your suggestion the error I get is the same as above with the error: process ID out of range. and it sais now that The 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. – Boris Month Jun 30 at 12:13
  • I just found out, that the install script also gives the same error when running it in the bash. So ther's actually something going wrong with the install script when I run it in my container. I 'solved' my problem by removing the lines with sed -i '50,101d' install_spinnaker.sh and now it does what I want it to do. Thank you. – Boris Month Jun 30 at 12:39
0

Turns out the error with the error: process ID out of range also came up when running it in the container with docker rum -ti bash. I just somehow didn't see the error and the installation was successful regardles. So I didn't notice and thought that the problem is somewhere with Docker which is not the case.

I managed to get what I want by removing all lines of the install_spinnaker.sh script I don't need, including the one which caused the error. It also removes a question, so there are now only two questions left in the script. To do that I do:

sed -i '50,101d' install_spinnaker.sh`

before running the script.

In the Dockerfile the layer now looks like:

RUN cd /app/spinnaker-1.23.0.27-amd64 && \
    sed -i '50,101d' install_spinnaker.sh && \
    printf 'y\nn\n' | sh install_spinnaker.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.