Dockerfile如何停止中止sudo提示并从bash脚本安装应用程序



我有一个Dockerfile,它运行bash脚本:

RUN curl -fsSL URL/remote-setup.sh | bash

$URL/remote-setup.sh片段

curl -L $URL/tarball/master | tar -xzv -C $HOME/output_dir --strip-components=1
. "$HOME/output_dir/setup.sh"

$HOME/output_dir/setup.sh片段

echo "Make sure we’re using the latest repositories"
apt update
echo " Upgrade any already-installed packages"
apt upgrade
apps=(
awscli
git
golang-go
mysql-server
postgresql postgresql-contrib
screenfetch
tig
tree
zip
zsh
)
echo "Installing..."
apt install "${apps[@]}"
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation

OUTPUT有错误

#12 6.126 Installing...
#12 6.128
#12 6.128 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
#12 6.128
#12 6.155 Reading package lists...
#12 6.699 Building dependency tree...
#12 6.829 Reading state information...
#12 6.965 The following additional packages will be installed:
...
#12 7.267 After this operation, 1498 MB of additional disk space will be used.
#12 7.267 Do you want to continue? [Y/n] Abort.
#12 7.271   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#12 7.272                                  Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 56.6M  100 56.6M    0     0  8848k      0  0:00:06  0:00:06 --:--:-- 13.2M
#12 13.83 ./dir/setup.sh: line 115: unzip: command not found
#12 13.84 sudo: ./sam-installation/install: command not found

CCD_ 3命令&找不到其他命令,因为未安装应用程序列表。它需要继续使用Y而不是中止

尝试添加ENV DEBIAN_FRONTEND noninteractive,但不起作用我该怎么修?感谢

您需要在安装命令的末尾添加-y。。。因此,apt在没有提示的情况下继续安装。。。所以,你的最终脚本应该是下面的样子

echo "Make sure we’re using the latest repositories"
apt update -y
echo " Upgrade any already-installed packages"
apt upgrade -y
apps=(
awscli
git
golang-go
mysql-server
postgresql postgresql-contrib
screenfetch
tig
tree
zip
zsh
)
echo "Installing..."
apt install "${apps[@]}" -y
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation

希望这能帮助。。。

最新更新