1. 登陆docker服务器绑定hosts

[root@docker ~]# vim /etc/hosts
[root@docker ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.137  harbor.scajy.org

2. docker登陆harbor镜像仓库

[root@docker ~]# docker login harbor.scajy.org
Username: admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

3. 上传到harbor镜像仓库

3.1 镜像打标签

[root@docker ~]# docker tag nginx:v1   harbor.scajy.org/scajy/nginx:v1

3.2 上传镜像

[root@docker ~]# docker push harbor.scajy.org/scajy/nginx:v1
The push refers to repository [harbor.scajy.org/scajy/nginx]
63fe338f5b3c: Pushed 
f9317b092a47: Pushed 
4ea9775fff9c: Pushed 
613be09ab3c0: Pushed 
v1: digest: sha256:b3ae6da4e2293ea54a5d50dbe8301d9c8256b3e6252201520d30fc92c9737079 size: 1161

4. 验证镜像

  • 验证镜像仓库下scajy是否有镜像,

  • 注释:

    ​ scajy在镜像仓库,就相当于我们可以做区分的dev或prod环境
    docker上传镜像到harbor镜像仓库
    docker上传镜像到harbor镜像仓库

5. 镜像仓库是http的地址需注意

  • 注意:

    是http提交,可以会出现仓库不信任

    [root@docker ~]# cat /etc/docker/daemon.json 
    {"registry-mirrors": ["http://f1361db2.m.daocloud.io"],
    "insecure-registries": ["http://192.168.3.173"]
    }
    重新启动
    [root@docker ~]# /bin/systemctl stop docker
    [root@docker ~]# /bin/systemctl start docker
    
    
  • 需要修改http信任后,方可才能提交