docker login harbor x509: certificate signed by unknown authority

Posted 牛奔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker login harbor x509: certificate signed by unknown authority相关的知识,希望对你有一定的参考价值。

前言

docker login harbor x509: certificate signed by unknown authority

解决

打开 /etc/docker/daemon.json,如果没有这个文件新增即可

vim /etc/docker/daemon.json

加入 insecure-registries


    "insecure-registries":["harbor.xxxx.com:1111"]

重启 docker

sudo systemctl docker

重新登录即可

docker login harbor.xxxx.com:1111

如果想从jenkins直接生成docker镜像,并推送到harbor中,最简单的脚本如何实现?

如果不考虑意外,

第一版最简单的构思如下:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import getopt, sys
import subprocess
import os


site_name = app_name = dep_version = war_name = ""
docker_harbor_ip = "x.x.x.x"
docker_login_name = "boss"
docker_login_password = "client"

#参数用法
def usage():
    print "./docker.py -s site -a app -d dev --war=war_name"
    sys.exit()

#获取参数
def get_opt():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hs:a:d:", ["help", "war="])
    except getopt.GetoptError:
        print "getopt function has error.."
        usage()
    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
        if o in ("-s"):
            site_name = a
        if o in ("-a"):
            app_name = a
        if o in ("-d"):
            dep_version = a
        if o in ("--war"):
            war_name = a
    return site_name, app_name, dep_version, war_name


#执行shell命令
def docker_cmd(cmd):
    return_code = subprocess.call(cmd, shell=True)
    if  return_code != 0:
        print "command === %s === error" % (cmd)
        usage()
    return return_code

def main():
    site_name, app_name, dep_version, war_name = get_opt()
    
    if "" in [site_name, app_name, dep_version, war_name]:
    print "args have empty value..."
        usage()
        
    docker_login = docker  login -u %s -p %s http://%s % (docker_login_name, docker_login_password, docker_harbor_ip )
    docker_tag = docker build -t %s/%s/%s:%s . % (docker_harbor_ip , site_name.lower(), app_name.lower(), dep_version)
    docker_push = docker push %s/%s/%s:%s % (docker_harbor_ip , site_name.lower(), app_name.lower(),dep_version)

    for cmd in [docker_login, docker_tag, docker_push]:
        docker_cmd(cmd)
    print "docker cmd is run..."
    
if __name__ ==__main__:
    main()

技术分享

 

技术分享

以上是关于docker login harbor x509: certificate signed by unknown authority的主要内容,如果未能解决你的问题,请参考以下文章

docker从私有镜像库pull/push镜像问题:Error response from daemon: Get https://harbor.op.xxxx.com/v2/: x509: cert

docker pull / docker login 报错 Error response from daemon: Get https://registry-1.docker.io/v2/: x509

docker pull / docker login 报错 Error response from daemon: Get https://registry-1.docker.io/v2/: x509

docker pull / docker login 报错 Error response from daemon: Get https://registry-1.docker.io/v2/: x509

Docker login harbor Error response from daemon: Get https

docker login Harbor时报错403 Forbidden