当我运行以下命令时,我正在尝试使用Dockerfile和shell脚本在debian:buster中安装mysql-server
apt install -y mysql-server,在安装过程中,我需要输入密码并重新键入,如图所示:

我做了一点搜索,发现如何在这个页面的Install MySQL on Ubuntu without a password prompt中使用here-string
因此,因为我使用这个命令apt install -y mysql-server,所以我是这样做的:
debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
apt-get -y install mysql-server但当我运行它们时,我仍然得到相同的东西,并且我需要输入密码。
这是我的Dockerfile:
From debian:buster
COPY ./run.sh /
CMD bash /run.sh这是run.sh:
apt update
apt install -y nginx gnupg wget lsb-release
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
printf "1\n1\n4\n" | dpkg -i mysql-apt-config_0.8.13-1_all.deb //version selected is mysql-5.7
apt update
service nginx start
bash //just to stay in the bash of container and don't quit from it.顺便说一句,我试图从容器的bash中安装mysql-server,然后我将在我的脚本中编写命令。
你可以在上面的图片中看到一些奇怪的东西,上面写着:
Configuring mysql-community-server
----------------------------------即使我是用这个命令apt-get -y install mysql-server安装的,也不是这个
apt-get -y install mysql-community-server
你知道我错过了什么吗?
发布于 2020-01-07 05:14:57
使用
shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password mypassword"
shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password mypassword"
shell> sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-serverhttps://stackoverflow.com/questions/59618948
复制相似问题