Is there a way to add a prompt during the docker build process?

Deadly 提交于 2019-12-18 19:08:57

问题


I'm using Docker to create a specific nginx container with SSL.

But I don't want my SSL files to be kept in my versionning system as is. Therefore they are encrypted. When building a docker container, I need the password to decrypt the files and test my nginx configuration.

I'm using read to get a prompt in my install script but Docker simply stops on the prompt:

 + echo 'Please enter the password for the SSL certificates: '
 + read -s SSL_PASSWORD
INFO[0008] The command [/bin/sh -c /build/setup.sh && /build/cleanup.sh] returned a non-zero code: 1

Is there some way to get a prompt when doing a docker build ?

Thanks for your help :)


回答1:


Well, after searching around, there's not way to have a prompt during a docker build. It has been designed to be fully automated.

I'll do this step during the docker run then.

Thanks to a certain larsks on the IRC #docker group, there's an interesting read about these issues at https://github.com/GoogleCloudPlatform/kubernetes/issues/2030

Thanks for helping out !




回答2:


Use expect command as it is like executing from a commandline. COPY expect script from docker host and run it.



来源:https://stackoverflow.com/questions/29432712/is-there-a-way-to-add-a-prompt-during-the-docker-build-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!