I have a script or "console" that starts during my docker build via my Dockerfile. When this is ran, it runs fine and opens its interactive prompt. My problem is, I can't seem to pass commands into that interactive prompt.

Here is the part of my dockerfile that matters:

    RUN ./iiq console
    RUN import init.xml
    RUN quit

I expect to see dependencies from init.xml brought in but instead I get:

Step 24/26 : RUN ./iiq console
 ---> Running in d1bf75e69674
Setting iiq.hostname to d1bf75e69674-console
> Removing intermediate container d1bf75e69674
 ---> 3832361dee0e
Step 25/26 : RUN import init.xml
 ---> Running in 8a3cd63c7789
/bin/sh: import: command not found

The greater than sign in the steps is opening this console and waiting for input it seems, I'm just not sure how to properly send it in. I can build my container without this step and do it manually so it works that way.


The Docker build process is completely non-interactive

Interactive command in Dockerfile

But I do this in a different, you may try this in your script.



echo "Arg is $1"

Here is my Dockerfile

FROM alpine
copy testargs.sh /testargs.sh
RUN chmod +x /testargs.sh
ARG arg1
RUN ./testargs.sh $arg1

Now Build the above dockerfile.

docker build --no-cache --build-arg arg1=testingarg1 -t test .

As you can see it's not interactive but at least it accepts the dyanmic argument.

enter image description here

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.