How to pass interactive response to RUN command in Dockerfile?

Some commands I want to RUN ask “yes/no” questions during execution and I need to be able to answer those during the build. How can I do that?

Here is my Dockerfile so far, during the SSH key generation it’s going to ask a few things like the passphrase among other things. I also plan to add other RUN commands that will most likely need interaction.

FROM php:5.6-apache

RUN apt-get update && apt-get upgrade -y

# Create the SSH Keys; mainly used for Git.
RUN apt-get install openssh-client
RUN ssh-keygen -t rsa

I found this, but I don’t think it’s what I want: Dockerfile how to answer install question from application