我有一个问题docker build ...
当尝试从私有 git 克隆存储库时该命令会中断。错误消息说我没有权限:
#17 4.712 转到:github.com/private/[电子邮件受保护]: 阅读github.com/private/project/go.mod
在修订版 v1.0.0 中:git ls-remote -q origin
in /go/pkg/mod/cache/vcs/<big-id>
:退出状态 128:
#17 4.712[电子邮件受保护]:权限被拒绝(公钥)。
#17 4.712 致命:无法从远程存储库读取。
#17 4.712
#17 4.712 请确保您拥有正确的访问权限
#17 4.712 并且存储库存在。
------
执行器运行失败 [/bin/sh -c cd cmd/service/ && go build -o service]:退出代码:1
我认为重要的要点我都有
# syntax=docker/dockerfile:experimental
FROM golang:alpine AS build-env
RUN apk add build-base git openssh-client
RUN mkdir -p -m 700 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh git clone [email protected]:myorg/myproject.git myproject
...
然后我使用包含以下内容的命令运行构建--ssh
export DOCKER_BUILDKIT=1
docker build --rm=false --no-cache --ssh default --file ./Dockerfile \
--build-arg GO_VERSION=1.16.3 --tag app:main .
The git clone ...
失败并出现上述错误。
还有--rm=false
没有影响,因为export DOCKER_BUILDKIT=1
。所以我不知道如何调试这个。我看不到任何容器,它们一旦被破坏就会被摧毁docker
命令返回...
我尝试改变--ssh
, 万一:
# The following gives me a permission error (as I expected)
... --ssh default=/home/alexis/.ssh/id_rsa ...
# The following is, I think, what happens by default, same git error
# (I verified the socket is under /run/user/1000/keyring/ssh
# as defined in the variable)
... --ssh github=$SSH_AUTH_SOCK ...
另外,在该文件中,mkdir
was 600
. 700
or 600
相同的差异。
所以我的问题是:在知道容器消失并且设置根本不想工作的情况下,如何调试 SSH 问题?
我在许多答案和文档中找到了很多信息,但它仍然不起作用,并且根本没有太多关于如何在失败时真正调试这样的设置。
- 在 docker 容器内使用 SSH 密钥
- 是否可以在正在运行的容器中启动 shell 会话(无需 ssh)
- 使用远程代理转发时docker buildkit挂载ssh
- 使用 Docker Compose 将主机的 SSH 密钥注入 Docker Machine
- 使用 SSH 访问构建中的私有数据
- 码头工人构建
$ docker version
Client:
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d28e
Built: Wed Aug 4 21:24:10 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Wed Aug 4 21:26:30 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit:
docker-init:
Version: 0.19.0
GitCommit: de40ad0