how to use here-strings in the Dockerfile?

拥有回忆 提交于 2020-02-08 10:00:33

问题


I am trying to install mysql-server in debian:buster using Dockerfile as you can see in the following code :

Dockerfile:

From debian:buster

RUN apt update

RUN apt install -y gnupg wget lsb-release

RUN wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb

RUN printf "1\n1\n4\n" | dpkg -i mysql-apt-config_0.8.13-1_all.deb

RUN apt update

RUN debconf-set-selections <<< 'mysql-community-server mysql-community-server/root-pass password your_password'

RUN debconf-set-selections <<< 'mysql-community-server mysql-community-server/re-root-pass password your_password'

RUN apt-get -y install mysql-server

CMD bash

and I wanted to install it non-interactively (without being asked any configuration questions), so I used debconf command, to do that but It doesn't work when I try to run it with RUN in the Dockerfile and this error occurs during the build :

So how can I use the here-strings in the Dockerfile?


回答1:


You don't need here-strings. You are already using the alternative earlier in your Dockerfile.

RUN printf '%s\n' 'mysql-community-server mysql-community-server/root-pass password your_password' | debconf-set-selections
RUN printf '%s\n' 'mysql-community-server mysql-community-server/re-root-pass password your_password' | debconf-set-selections

echo doesn't behave consistently across otherwise POSIX-compliant implementations; prefer printf instead.



来源:https://stackoverflow.com/questions/59635714/how-to-use-here-strings-in-the-dockerfile

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