解决Dockerfile中git clone containerd失败:'gnutls_handshake() failed'错误
在Dockerfile中使用git clone命令下载containerd源代码时,你可能会遇到以下错误:
fatal: unable to access 'https://github.com/containerd/containerd.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
这个错误可能是由于代理设置不正确或者网络连接问题导致的。可以尝试以下几种解决方法:
-
检查代理设置是否正确,确保代理服务器地址、端口和协议(HTTP或HTTPS)正确。
-
如果代理设置正确,尝试使用其他网络连接,例如切换到不同的WiFi网络或使用移动数据连接。
-
如果以上方法都不起作用,可以尝试使用
git clone命令手动下载containerd源代码,然后在Dockerfile中使用COPY命令将代码复制到容器中。 -
如果还是无法解决问题,可以尝试联系GitHub支持团队或网络管理员寻求帮助。
参考代码:
FROM base AS containerd-src
WORKDIR /usr/src/containerd
RUN git init . && git remote add origin 'https://github.com/containerd/containerd.git'
# CONTAINERD_VERSION is used to build containerd binaries, and used for the
# integration tests. The distributed docker .deb and .rpm packages depend on a
# separate (containerd.io) package, which may be a different version as is
# specified here. The containerd golang package is also pinned in vendor.mod.
# When updating the binary version you may also need to update the vendor
# version to pick up bug fixes or new APIs, however, usually the Go packages
# are built from a commit from the master branch.
ARG CONTAINERD_VERSION=v1.7.0
ENV HTTP_PROXY=http://192.168.44.37:7890
ENV HTTPS_PROXY=https://192.168.44.37:7890
RUN git fetch -q --depth 1 origin '$CONTAINERD_VERSION' +refs/tags/*:refs/tags/* && git checkout -c http.sslVerify=false -q FETCH_HEAD
原文地址: https://www.cveoy.top/t/topic/gRcY 著作权归作者所有。请勿转载和采集!