首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Dockerfile运行来克隆bitbucket回购

使用Dockerfile运行来克隆bitbucket回购
EN

Stack Overflow用户
提问于 2018-10-04 16:27:55
回答 1查看 1.5K关注 0票数 0

运行时,我试图从dockerfile中克隆bitbucket存储库

代码语言:javascript
复制
docker build -t newapi .

到目前为止,Dockerfile看起来像

代码语言:javascript
复制
FROM node:alpine
EXPOSE 3000
RUN git clone https://user:password@bitbucket.org/something/api.git

如果我在控制台中单独运行git克隆命令,它可以工作,已经测试过了,我在表单中使用它

代码语言:javascript
复制
git clone https://user:password@bitbucket.org/something/api.git

我试图以多种方式使用RUN命令,这会给我带来不同的错误:

1.

代码语言:javascript
复制
 RUN git clone https://user:password@bitbucket.org/something/api.git

抛出:

代码语言:javascript
复制
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.

代码语言:javascript
复制
RUN ["/bin/bash", "-c", "git clone https://user:password@bitbucket.org/something/api.git"]

抛出:

代码语言:javascript
复制
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.

代码语言:javascript
复制
RUN ["git", "clone", "https://user:password@bitbucket.org/something/api.git"]

抛出:

代码语言:javascript
复制
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.

代码语言:javascript
复制
RUN ["/bin/sh", "-c", "git clone https://user:password@bitbucket.org/something/api.git"]

抛出:

代码语言:javascript
复制
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克隆.“避免命令的前面有什么东西?或者做我想做的事的方法是什么?

我正在使用macOS Mojave10.14和DockerVersion18.06.1-ce-mac73 (26764),如果这有帮助的话

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-04 16:37:13

您必须安装git包:

代码语言:javascript
复制
RUN apk add --no-cache git
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52651504

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档