I tried to install something using dockerfile. But when I run the command, I have to answer the question like following:
enter
6
72
My dockfile is like following, but seems not working.
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y expect
RUN apt-get -y install software-properties-common
RUN apt-add-repository ppa:ondrej/php
expect “Press [ENTER] to continue or Ctrl-c to cancel adding it. ” { send “\n” }
RUN apt-get -y install php7.1 php7.1-fpm
expect “Please select the geographic area in which you live. ” { send “6\n” }
expect “Please select the city or region corresponding to your time zone. ” { send “72\n” }
RUN -y apt-get install nginx
Anyone tell me how to answer install question in dockerfile?
I tested your Dockerfile and didn't have to answer any question, but if you want to auto answer when you run a command, you can use yes
(for "y" and "n" responses) or echo
.
Ex:
yes | <YOUR COMMAND>
yes n | <YOUR COMMAND>
"n" response
echo | <YOUR COMMAND>
echo generate a new line (enter)
echo "some response" | <YOUR COMMAND>
response with "some response"
If you have multiple questions to answer :
printf "answer1\nanswer2\nanswer3" | <your_script.sh>
The individual answers are separated by a \n
character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With