【发布时间】:2020-04-27 12:20:12
【问题描述】:
在基于 alpine linux 的 docker 的入口点脚本中,我有以下几行:
#!/bin/sh
echo "============== START ============"
echo $@
NOLOAD=0
FILE=""
RET=1
if [ ! -f /initialized ]; then
echo "not initialized"
apk add --virtual .init-deps bash
echo "bash installed"
echo "Building from server"
apk add --virtual .init-deps git
echo "git installed"
bash load_git.sh "${GIT_SERVER}" "${GIT_USERNAME}" "${GIT_PASSWORD}" "${GIT_BRANCH}"
RET=$?
echo cloning done
fi
echo "just before purging all dependencies"
apk --purge del .init-deps
我希望安装 bash 以及 git 并使用 bash 运行 load_git.sh 脚本。我每隔一行进行一次文学记录,但在运行 load_git.sh 脚本之前得到了一些奇怪的结果:
============== START ============
not initialized
(1/6) Installing ncurses-terminfo-base (6.1_p20191130-r0)
(2/6) Installing ncurses-terminfo (6.1_p20191130-r0)
(3/6) Installing ncurses-libs (6.1_p20191130-r0)
(4/6) Installing readline (8.0.1-r0)
(5/6) Installing bash (5.0.11-r1)
Executing bash-5.0.11-r1.post-install
(6/6) Installing .init-deps (20200109.202215)
Executing busybox-1.31.1-r8.trigger
OK: 18 MiB in 24 packages
bash installed
Building from server
(1/12) Installing ca-certificates (20191127-r0)
(2/12) Installing nghttp2-libs (1.40.0-r0)
(3/12) Installing libcurl (7.67.0-r0)
(4/12) Installing expat (2.2.9-r1)
(5/12) Installing pcre2 (10.34-r1)
(6/12) Installing git (2.24.1-r0)
(7/12) Upgrading .init-deps (20200109.202215 -> 20200109.202216)
(8/12) Purging bash (5.0.11-r1)
Executing bash-5.0.11-r1.pre-deinstall
(9/12) Purging readline (8.0.1-r0)
(10/12) Purging ncurses-libs (6.1_p20191130-r0)
(11/12) Purging ncurses-terminfo (6.1_p20191130-r0)
(12/12) Purging ncurses-terminfo-base (6.1_p20191130-r0)
Executing busybox-1.31.1-r8.trigger
Executing ca-certificates-20191127-r0.trigger
OK: 25 MiB in 25 packages
git installed
/init.sh: line 17: bash: not found
cloning done
outside if statement to get source
just before purging all dependencies
Build failed, starting shell
我无法理解这样一个事实,即在安装 git 时它还会清除 bash,这完全没有意义。
编辑:只有在 Synology nas 中通过 ssh 连接启动 docker 时才会发生这种情况,当使用本地 docker 映像并在本地启动它时,它工作得非常好。
【问题讨论】:
-
load_git.sh 中有什么?
-
另一个脚本(应该下载已经从 git 审查过的最新版本)。 - 脚本顶部有一个回声,我知道它没有运行。只输入
echo "outdir"表明两者之一(也没有设置返回变量)。