运行时,我试图从dockerfile中克隆bitbucket存储库
docker build -t newapi .到目前为止,Dockerfile看起来像
FROM node:alpine
EXPOSE 3000
RUN git clone https://user:password@bitbucket.org/something/api.git如果我在控制台中单独运行git克隆命令,它可以工作,已经测试过了,我在表单中使用它
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: 1272.
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": unknown3.
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": unknown4.
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克隆.“避免命令的前面有什么东西?或者做我想做的事的方法是什么?
我正在使用macOS Mojave10.14和DockerVersion18.06.1-ce-mac73 (26764),如果这有帮助的话
发布于 2018-10-04 16:37:13
您必须安装git包:
RUN apk add --no-cache githttps://stackoverflow.com/questions/52651504
复制相似问题