Dockerfile ask the user a value

0

Good afternoon colleagues, I'm working with Docker in the construction of some images and I've found that some facilities ask the user questions such as a password.

There is the possibility of questioning the user during the process of creating the image and then passing that passage for another command, for example this code sends me an error

FROM ubuntu:16.04 SHELL ["/bin/bash", "-c"] RUN ["echo","========== Enter root password for db =========="] RUN ["/bin/bash","read","pass"] > Error al momento de compilar RUN debconf-set-selections <<< "mysql-server mysql-server/root_password password $pass" RUN debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $pass"

The error message is as follows:

The command '/bin/bash read pass' returned a non-zero code: 127

    
asked by Victor Barajas 22.11.2017 в 01:40
source

1 answer

0

There is no interactive mode in docker build as there is in docker run , if you want to pass construction parameters you can use --build-args (see here) and make a script that asks for those values and execute docker build with that option.

PS: To manage passwords, it is recommended to use secrets. MySQL explains how to do it with docker-compose (view) and Docker with% % co for production (view)

    
answered by 23.11.2017 / 13:07
source