我试图在Makefile
码头工具中运行此alpine
。
SHELL := /bin/bash
build:
GOOS=linux go build -o bin/server main.go
我已确定bash
,make
,go
都是通过交互式进入容器并检查所有命令而存在的。
但是这个命令神秘地失败了:
+ make build
make: /bin/bash: Command not found
GOOS=linux go build -o bin/server main.go
make: /bin/bash: Command not found
make: *** [Makefile:17: build] Error 127
script returned exit code 2
我很难在Docker中调试它,而jenkins
正在执行所有操作。
答案 0 :(得分:3)
高山没有/bin/bash
:
$ docker run -i -t alpine
/ # ls /bin/bash
ls: /bin/bash: No such file or directory
请注意,两者都没有make
或go
。所以,要么你在宿主而不是在高山上检查它们的存在,要么你没有使用香草高山。
答案 1 :(得分:3)
以这种方式使用名为apk的包管理器:
% docker run --rm -it alpine /bin/sh
/ #
/ # apk add --no-cache bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.0-r8)
(2/5) Installing ncurses-terminfo (6.0-r8)
(3/5) Installing ncurses-libs (6.0-r8)
(4/5) Installing readline (6.3.008-r4)
(5/5) Installing bash (4.3.46-r5)
Executing bash-4.3.46-r5.post-install
Executing busybox-1.25.1-r0.trigger
OK: 12 MiB in 16 packages
/ # which -a bash
/bin/bash
答案 2 :(得分:0)
要使用Alpine Package Keeper(APK)添加bash
,请使用以下命令:
apk update
apk add --no-cache bash
不要忘记将bash
设置为默认外壳:
apk add --no-cache shadow
chsh -s /bin/bash
exec /bin/bash