使用 Dockerfile 运行 克隆一个 bitbucket 仓库
Using Dockerfile RUN to clone a bitbucket repo
我在 运行ning
时尝试从 dockerfile 克隆一个 bitbucket 存储库
docker build -t newapi .
到目前为止Docker文件看起来像
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
并且我尝试以多种方式使用 运行 命令,这给了我不同的错误:
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) 如果有帮助的话
您必须安装 git 软件包:
RUN apk add --no-cache git
我在 运行ning
时尝试从 dockerfile 克隆一个 bitbucket 存储库docker build -t newapi .
到目前为止Docker文件看起来像
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
并且我尝试以多种方式使用 运行 命令,这给了我不同的错误:
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) 如果有帮助的话
您必须安装 git 软件包:
RUN apk add --no-cache git