MightySuo
MightySuo

Reputation: 23

Use STDIN during docker build from a Dockerfile

I'm trying to install Miniconda in a docker image as a first step, right now this is what I have:

    FROM ubuntu:14.04
RUN apt-get update && apt-get install wget
RUN wget *miniconda download URL* && bash file_downloaded.sh

When I try to build the image, it goes well until it starts popping the following message continously: >>> Please answer 'yes' or 'no' At that point I need to stop docker build. How can I fix it? Should I include something in the dockerfile?

Upvotes: 2

Views: 4062

Answers (2)

Ashish Bista
Ashish Bista

Reputation: 4693

You can't attach interactive tty during image build. If it is asking for 'yes' or 'no' during package installation, wget in your case, you can replace the corresponding line with RUN apt-get update -qq && apt-get install -y wget. If it is bash file_downloaded.sh, check if file_downloaded.sh accepts 'yes' or 'no' as a command line argument.

If file_downloaded.sh doesn't have that option, create a container from ubuntu:14.04 image, install wget and run your commands manually there. Then, you can make an image of the container by committing your changes like: docker commit <cotainer_id> <image_name>.

Upvotes: 2

Vor
Vor

Reputation: 35109

I believe you can pass -b flag to miniconda shell script to avoid manual answering

Installs Miniconda3 4.0.5

    -b           run install in batch mode (without manual intervention),
                 it is expected the license terms are agreed upon
    -f           no error if install prefix already exists
    -h           print this help message and exit
    -p PREFIX    install prefix, defaults to $PREFIX

something like that:

RUN wget http://......-x86_64.sh -O miniconda.sh
RUN chmod +x miniconda.sh \
    && bash ./miniconda.sh -b

Upvotes: 1

Related Questions