此问题在此处已有答案:
The command '/bin/sh -c apt-get install dnsutils' returned a non-zero code: 1(2个答案)
2天前关闭。
我有一个Dockerfile,它可以获取并运行一个bash脚本,如下所示:Dockerfile
程式码片段
ENV USERNAME user
ENV USERPASSWORD user
# Create and configure user
RUN useradd -ms /bin/bash $USERNAME
# User with empty password
RUN echo "$USERNAME:$USERPASSWORD" | chpasswd
# Enable passwordless sudo for user
RUN mkdir -p /etc/sudoers.d && \
echo "$USERNAME ALL= NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
# Get & run install script
RUN curl -L 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
找不到unzip
命令和其他命令,因为未安装应用程序列表。需要继续执行Y
,而不是中止
尝试添加ENV DEBIAN_FRONTEND noninteractive
,但不工作,我如何修复它?谢谢
1条答案
按热度按时间w1jd8yoj1#
您需要在安装命令的末尾添加
-y
...这样,apt就可以继续安装,而不会出现提示...因此,您的最终脚本应该如下所示希望这对你有帮助...