简体   繁体   English

从 docker 容器访问私有存储库

[英]Accessing a private repository from a docker container

I am trying to build a docker image using a dockerfile我正在尝试使用 dockerfile 构建 docker 图像

the problem is when the instruction apt-get update get executed I get this error问题是当指令apt-get update被执行时我得到这个错误

Err:8 https://artifactory-name bionic-updates Release
  Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.  Could not handshake: Error in the certificate verification. [IP: artifactory-ip]

So I want to know if the docker container reuse the certificates configured in my host machine所以我想知道 docker 容器是否重用了我主机中配置的证书

or there is a configuration i must add in order to access the artifactory from my container.或者我必须添加一个配置才能从我的容器访问工件。

Ps: my host machine is ubuntu and I have no problem accessing the artifactory ps:我的主机是ubuntu,访问神器没问题

Try to install ca-certificates before: sudo apt install ca-certificates or if you want to bypass the security add [trusted=yes] in the sources.list尝试安装 ca-certificates 之前: sudo apt install ca-certificates或者如果您想绕过安全添加[trusted=yes]sources.list

It's quite common that docker base images have root CA certificates that are out of date. docker 基本映像具有过期的根 CA 证书是很常见的。 (root CA certs are the ones that browsers and operating systems have built-in so they are always trusted, those certs still change but are usually updated automatically). (根 CA 证书是浏览器和操作系统内置的证书,因此它们始终受到信任,这些证书仍然会更改,但通常会自动更新)。

So it's common to start a Dockerfile with commands needed to bring those certs up to date.因此,使用更新这些证书所需的命令启动 Dockerfile 是很常见的。 Here are two commands for Debian based images:以下是基于 Debian 的图像的两个命令:

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
       apt-transport-https

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
       ca-certificates \

The first ensures that apt can read SSL/TLS sources.第一个确保apt可以读取 SSL/TLS 源。 The second updates those root CA certs.第二个更新那些根 CA 证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM