Dockerfile how to answer install question from application

I would like to make a docker image based on a application that during its install asks you a bunch of yes or no question in regards to how you want the application installed…

how would a answer these with the dockerfile?

like the file would say

run apt-get install application

would the above example be correct? or would you need to something else?

i hope i explained myself i found it hard to put this down in text :smile:

Best regards

Ding IT

You can try to pipe the yes/no to your installation script.
RUN sh -c ‘/bin/echo -e “yes\nyes\nyes\nno\nyes\nno” | your_script’

or you can try too with expect

RUN apt-get install expect
ADD install_script
RUN install_script

where install_script is
set timeout 2
spawn "./your_script"
expect “Question 1 :” { send “yes\n” }
expect “Question 2 :” { send “no\n” }

Hi slamp,

Wouldn’t it also work with me pulling a image for say centos. make a docker centos using the image login and install the application the “old fashion” way and then create a new image based on that running one?

Yes you can do that.
To detach the tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q. The container will continue to exist in a stopped state once exited.
Then commit your change:
docker commit docker_id docker_name_application