安装Docker后,可以通过官方提供的registry镜像来简单搭建一套本地私有仓库环境,本文记录简单的搭建过程。

1 使用registry启动私有仓库的容器

docker run -d -p 5000:5000 -v /root/my_registry:/tmp/registry registry

说明:若之前没有安装registry容器则会自动下载并启动一个registry容器,创建本地的私有仓库服务。默认情况下,会将仓库创建在容器的/tmp/registry目录下,可以通过 -v 参数来将镜像文件存放在本地的指定路径上(例如,放在本地目录/root/my_registry下)。

2 向私有仓库push镜像

docker push 104.131.173.242:5000/ubuntu_sshd_gcc_gerry:14.04

说明:根据第一步启动的registry容器所在宿主主机的IP和Port,push某环境的本地容器。

root@gerryyang:~# docker push 104.131.173.242:5000/ubuntu_sshd_gcc_gerry:14.04 
The push refers to a repository [104.131.173.242:5000/ubuntu_sshd_gcc_gerry] (len: 1) 
Sending image list 
Pushing repository 104.131.173.242:5000/ubuntu_sshd_gcc_gerry (1 tags) 
511136ea3c5a: Image successfully pushed 
3b363fd9d7da: Image successfully pushed 
607c5d1cca71: Image successfully pushed 
f62feddc05dc: Image successfully pushed 
8eaa4ff06b53: Image successfully pushed 
894c0161121f: Image successfully pushed 
a45787b0222f: Image successfully pushed 
f0e3262ed661: Image successfully pushed 
Pushing tag for rev [f0e3262ed661] on {http://104.131.173.242:5000/v1/repositories/ubuntu_sshd_gcc_gerry/tags/14.04} 

宿主主机my_registry的目录结构

 root@gerryyang:~/my_registry# tree 
. 
├── images 
│  ├── 3b363fd9d7dab4db9591058a3f43e806f6fa6f7e2744b63b2df4b84eadb0685a 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  ├── 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  ├── 607c5d1cca71dd3b6c04327c3903363079b72ab3e5e4289d74fb00a9ac7ec2aa 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  ├── 894c0161121f105ac9b81bca7ac583ac1f29772625911db0fa2b6b475f5642fd 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  ├── 8eaa4ff06b53ff7730c4d7a7e21b4426a4b46dee064ca2d5d90d757dc7ea040a 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  ├── a45787b0222f955d68d9db34fb18033144b8a78015d9e306a1613894da0fd86e 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  ├── f0e3262ed6617896b306852c923e4c0e1d359b58b29a02ef849c4b8978c73c65 
│  │  ├── ancestry 
│  │  ├── _checksum 
│  │  ├── json 
│  │  └── layer 
│  └── f62feddc05dc67da9b725361f97d7ae72a32e355ce1585f9a60d090289120f73 
│    ├── ancestry 
│    ├── _checksum 
│    ├── json 
│    └── layer 
└── repositories 
  └── library 
    └── ubuntu_sshd_gcc_gerry 
      ├── _index_images 
      ├── tag_14.04 
      └── tag14.04_json 
 
12 directories, 35 files 

关于https的问题

root@gerryyang:~# docker push 104.131.173.242:5000/ubuntu_sshd_gcc_gerry:14.04 
FATA[0002] Error: Invalid registry endpoint https://104.131.173.242:5000/v1/: Get https://104.131.173.242:5000/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 104.131.173.242:5000` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/104.131.173.242:5000/ca.crt  

解决方法:

修改Docker配置文件

vim /etc/default/docker

增加以下一行

DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=104.131.173.242:5000"

重启Docker

sudo service docker restart

3 私有仓库查询方法

curl http://104.131.173.242:5000/v1/search

说明:使用curl查看仓库104.131.173.242:5000中的镜像。在结果中可以查看到ubuntu_sshd_gcc_gerry,说明已经上传成功了。

gerryyang@mba:personal_repository$curl http://104.131.173.242:5000/v1/search 
{"num_results": 0, "query": "", "results": []} 
gerryyang@mba:personal_repository$curl http://104.131.173.242:5000/v1/search 
{"num_results": 1, "query": "", "results": [{"description": "", "name": "library/ubuntu_sshd_gcc_gerry"}]} 

4 在其他的机器上访问和下载私有仓库的镜像

docker pull 104.131.173.242:5000/ubuntu_sshd_gcc_gerry:14.04
root@gerryyang:~# docker pull 104.131.173.242:5000/ubuntu_sshd_gcc_gerry:14.04 
Pulling repository 104.131.173.242:5000/ubuntu_sshd_gcc_gerry 
f0e3262ed661: Download complete  
511136ea3c5a: Download complete  
3b363fd9d7da: Download complete  
607c5d1cca71: Download complete  
f62feddc05dc: Download complete  
8eaa4ff06b53: Download complete  
894c0161121f: Download complete  
a45787b0222f: Download complete  
Status: Image is up to date for 104.131.173.242:5000/ubuntu_sshd_gcc_gerry:14.04 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

标签:
docker,registry,镜像,docker,私有镜像仓库,docker,创建私有仓库

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。