docker從私有倉庫Harbor, push 及 pull 鏡像

1.配置docker 私有倉庫地址linux

#1.centos7
vi /usr/lib/systemd/system/docker.service
#加上 --insecure-registry 倉庫地址:端口
ExecStart=/usr/bin/dockerd --insecure-registry 192.168.2.108:5000

#2.or
修改/etc/sysconfig/docker(Ubuntu下配置文件地址爲:/etc/init/docker.conf),增長啓動選項(已有參數的在後面追加),以後重啓docker,不添加報錯,https證書問題。

OPTIONS='--insecure-registry 192.168.0.179:5000'    #CentOS 7系統
other_args='--insecure-registry 192.168.0.179:5000' #CentOS 6系統

#加載配置
systemctl daemon-reload
#從新啓動docker
systemctl restart docker

2.查看配置是否生效docker

[root@lee make]# docker info
Containers: 7
 Running: 7
 Paused: 0
 Stopped: 0
Images: 7
Server Version: 17.06.2-ce
Storage Driver: overlay
 Backing Filesystem: xfs
 Supports d_type: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 6e23458c129b551d5c9871e5174f6b1b7f6d1170
runc version: 810190ceaa507aa2727d7ae6f4790c76ec150bd2
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.781GiB
Name: lee
ID: ETGX:C33D:SCFK:OGIT:WJKT:SBEC:AC3B:Y5IR:P6I6:D5EE:TYI6:DKNA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
#成功
 192.168.2.108:5000
 127.0.0.0/8
Registry Mirrors:
 https://3sd5xx7k.mirror.aliyuncs.com/
 https://hub.c.163.com/
 http://ac72eb49.m.daocloud.io/
Live Restore Enabled: false

3.登陸Harborjson

#不加端口
[root@lee make]# docker login 192.168.2.108
Username: admin
Password: 
Error response from daemon: Get https://192.168.2.108/v2/: dial tcp 192.168.2.108:443: getsockopt: connection refused
#加端口
[root@lee make]# docker login 192.168.2.108:5000
Username (admin): admin
Password: 
Login Succeeded
[root@lee make]#

4.登陸Harbor並添加項目centos

#登陸Harobr (http://ip)
#默認用戶名 admin ,默認 Harbor12345

5.上傳及下載鏡像到Harbortcp

#1.標記鏡像
docker tag {鏡像名}:{tag} {Harbor地址}:{端口}/{Harbor項目名}/{自定義鏡像名}:{自定義tag}
#eg:docker tag vmware/harbor-adminserver:v1.1.0 192.168.2.108:5000/test/harbor-adminserver:v1.1.0

#2.push 到Harbor
docker push {Harbor地址}:{端口}/{自定義鏡像名}:{自定義tag}
#eg:docker push 192.168.2.108:5000/test/harbor-adminserver:v1.1.0

3.pull 到本地
docker pull 192.168.2.108:5000/test/harbor-adminserver:v1.1.0
相關文章
相關標籤/搜索