我正在尝试在运行时从dockerfile克隆一个bitbucket存储库
docker build -t newapi .
到目前为止,Dockerfile看起来像
FROM node:alpine
EXPOSE 3000
RUN git clone https://user:password@bitbucket.org/something/api.git
如果我在一个可以正常运行的控制台中运行git clone命令,并且已经对其进行了测试,那么我将以以下形式使用它
git clone https://user:password@bitbucket.org/something/api.git
我尝试通过多种方式使用RUN命令,这些错误会给我带来不同的错误:
1。
RUN git clone https://user:password@bitbucket.org/something/api.git
投掷:
Step 6/13 : RUN git clone https://user:password@bitbucket.org/something/api.git
---> Running in 9a748f75ff66
/bin/sh: git: not found
The command '/bin/sh -c git clone https://user:password@bitbucket.org/something/api.git' returned a non-zero code: 127
2。
RUN ["/bin/bash", "-c", "git clone https://user:password@bitbucket.org/something/api.git"]
投掷:
Step 6/13 : RUN ["/bin/bash", "-c", "git clone https://user:password@bitbucket.org/something/api.git"]
---> Running in dc7c373071c2
OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
3。
RUN ["git", "clone", "https://user:password@bitbucket.org/something/api.git"]
投掷:
Step 6/13 : RUN ["git", "clone", "https://user:password@bitbucket.org/something/api.git"]
---> Running in b797b442d1fc
OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"git\": executable file not found in $PATH": unknown
4。
RUN ["/bin/sh", "-c", "git clone https://user:password@bitbucket.org/something/api.git"]
投掷:
Step 6/13 : RUN ["/bin/sh", "-c", "git clone https://user:password@bitbucket.org/something/api.git"]
---> Running in 2fe387a213f3
/bin/sh: git: not found
The command '/bin/sh -c git clone https://user:password@bitbucket.org/something/api.git' returned a non-zero code: 127
我不知道要尝试什么,我尝试使用bash,因为有人说它与git更好地工作,并尝试使用在其之前使用“ / bin / sh -c”运行的原始代码。有没有一种方法可以只执行“ git clone ...”并避免在命令前添加内容?还是做我想做的事情的方式是什么?
如果有帮助,我正在使用macOS Mojave 10.14和Docker版本18.06.1-ce-mac73(26764)
答案 0 :(得分:2)
您必须安装git软件包:
RUN apk add --no-cache git