# Dockerfile how to answer install question from application

**URL:** <https://forums.docker.com/t/dockerfile-how-to-answer-install-question-from-application/5240>\
**Category:** General\
**Tags:** docker\
**Created:** [December 23, 2015, 6:28am UTC](https://forums.docker.com/t/dockerfile-how-to-answer-install-question-from-application/5240 "2015-12-23T06:28:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dingit](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dingit](https://forums.docker.com/u/dingit)\
**Post date:** [December 23, 2015, 6:28am UTC](https://forums.docker.com/t/dockerfile-how-to-answer-install-question-from-application/5240/1 "2015-12-23T06:28:42Z")

</div>

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  
yes  
yes  
yes  
no  
yes  
no

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 😄

Best regards

Casper  
Ding IT

---

<div class="post-metadata">

**Author:** ![slamp](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/slamp/32/3414_2.png) [@slamp](https://forums.docker.com/u/slamp)\
**Post date:** [December 23, 2015, 9:28pm UTC](https://forums.docker.com/t/dockerfile-how-to-answer-install-question-from-application/5240/2 "2015-12-23T21:28:23Z")

</div>

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  
#!/usr/bin/expect  
set timeout 2  
spawn "./your\_script"  
expect “Question 1 :” { send “yes\n” }  
expect “Question 2 :” { send “no\n” }  
interact

---

<div class="post-metadata">

**Author:** ![dingit](https://avatars.discourse-cdn.com/v4/letter/d/c6cbf5/32.png) [@dingit](https://forums.docker.com/u/dingit)\
**Post date:** [December 25, 2015, 5:10am UTC](https://forums.docker.com/t/dockerfile-how-to-answer-install-question-from-application/5240/3 "2015-12-25T05:10:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![slamp](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/slamp/32/3414_2.png) [@slamp](https://forums.docker.com/u/slamp)\
**Post date:** [February 6, 2016, 4:20pm UTC](https://forums.docker.com/t/dockerfile-how-to-answer-install-question-from-application/5240/4 "2016-02-06T16:20:01Z")

</div>

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
