您的位置:首页 > 运维架构 > Docker

docker从私有仓库Harbor, push 及 pull 镜像

2017-09-24 00:00 1096 查看
1.配置docker 私有仓库地址

#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.查看配置是否生效

[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.登录Harbor

#不加端口
[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并添加项目

#登录Harobr (http://ip)
#默认用户名 admin ,默认 Harbor12345




5.上传及下载镜像到Harbor

#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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Docker Docker-Registry