Skip to content

Commit

Permalink
fix debian can not docker pull
Browse files Browse the repository at this point in the history
In debian, when build docker images, error message as blows:
root@2288hv5-2s44p-384g--b5 /c/compass-ci/container/dnsmasq# ./build
Sending build context to Docker daemon  12.29kB
Step 1/6 : FROM alpine:3.11
Get "https://registry-1.docker.io/v2/": x509: certificate signed by
unknown authority

The old code just support openEuler and centos, not support debian,
so call docker_ca_certificate() to trust the certificate according
to different OS.

Refer:
https://docs.docker.com/registry/insecure/

Signed-off-by: Wang Chongyang <[email protected]>
  • Loading branch information
dearwangcy authored and caoxueliang007 committed May 26, 2022
1 parent fd3d6ce commit 69fb0d7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bin/lkp-setup-rootfs
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,34 @@ EOF
return 0
}

docker_ca_certificate()
{
crt_file=$1
mkdir -p $crt_file
curl http://$DOCKER_PROXY_HOST:$DOCKER_PROXY_PORT/ca.crt > \
"${crt_file}"/docker_registry_proxy.crt || return
}

install_docker_proxy()
{
[ -n "$DOCKER_PROXY_HOST" ] || return 0
[ -n "$DOCKER_PROXY_PORT" ] || return 0

mkdir -p /etc/pki/ca-trust/source/anchors
curl http://$DOCKER_PROXY_HOST:$DOCKER_PROXY_PORT/ca.crt > \
/etc/pki/ca-trust/source/anchors/docker_registry_proxy.crt || return

mkdir -p /etc/systemd/system/docker.service.d
cat << EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTPS_PROXY=http://$DOCKER_PROXY_HOST:$DOCKER_PROXY_PORT/"
EOF

update-ca-trust extract
has_cmd update-ca-trust && {
docker_ca_certificate /etc/pki/ca-trust/source/anchors
update-ca-trust extract
}

has_cmd update-ca-certificates && {
docker_ca_certificate /usr/local/share/ca-certificates/
update-ca-certificates
}

systemctl daemon-reload
has_cmd docker && systemctl restart docker.service
Expand Down

0 comments on commit 69fb0d7

Please sign in to comment.