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 is it possible to use here-strings in a Dockerfile?
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.