从无到有创建自己的Docker私有仓库

由于GFW的关系,国内用户在使用docker的时候,pull一个基本的镜像都拉下来,更不用说使用官方的index镜像了。差点放弃使用docker了,google了一圈,总算找到办法。

第一步:安装docker

参见官方指南或则各类中文指南

比如下面这两篇:

Docker的搭建Gitlab CI 全过程详解

Docker安装应用(CentOS 6.5_x64)

第二步:从文件系统创建一个image镜像

创建镜像有很多方法,官方的推荐是pull一个,无奈GFW,想下一个基本的Ubuntu都下不下来

还有一个办法就是从一个文件系统import一个镜像,个人推荐可以使用opvz的模板来创建:

openvz的模板下载地址如下:

centos-5-x86-devel.tar.gz (signature)2014-07-21 22:37:33197 Mb
centos-5-x86.tar.gz (signature)2014-07-21 22:36:20174 Mb
centos-5-x86_64-devel.tar.gz (signature)2014-07-21 22:39:56208 Mb
centos-5-x86_64.tar.gz (signature)2014-07-21 22:38:41184 Mb
centos-6-x86-devel.tar.gz (signature)2014-07-21 22:31:38234 Mb
centos-6-x86-minimal.tar.gz (signature)2014-07-21 22:30:16103 Mb
centos-6-x86.tar.gz (signature)2014-07-21 22:29:33203 Mb
centos-6-x86_64-devel.tar.gz (signature)2014-07-21 22:35:13249 Mb
centos-6-x86_64-minimal.tar.gz (signature)2014-07-21 22:33:48103 Mb
centos-6-x86_64.tar.gz (signature)2014-07-21 22:33:04215 Mb
centos-7-x86_64-minimal.tar.gz (signature)2014-07-21 22:41:55131 Mb
centos-7-x86_64.tar.gz (signature)2014-07-21 22:41:05201 Mb
debian-6.0-x86-minimal.tar.gz (signature)2014-07-21 22:26:5177 Mb
debian-6.0-x86.tar.gz (signature)2014-07-21 22:26:18148 Mb
debian-6.0-x86_64-minimal.tar.gz (signature)2014-07-21 22:28:2079 Mb
debian-6.0-x86_64.tar.gz (signature)2014-07-21 22:27:49150 Mb
ebian-7.0-x86-minimal.tar.gz (signature)2014-07-21 22:23:3784 Mb
debian-7.0-x86.tar.gz (signature)2014-07-21 22:23:05224 Mb
debian-7.0-x86_64-minimal.tar.gz (signature)2014-07-21 22:25:2284 Mb
debian-7.0-x86_64.tar.gz (signature)2014-07-21 22:24:49224 Mbf
edora-19-x86.tar.gz (signature)2014-07-21 22:11:34189 Mb
Fedora-19-x86_64.tar.gz (signature)2014-07-21 22:12:48190 Mb
fedora-20-x86.tar.gz (signature)2014-07-21 22:09:10184 Mb
fedora-20-x86_64.tar.gz (signature)2014-07-21 22:10:20184 Mb
scientific-6-x86.tar.gz (signature)2014-07-21 22:43:09197 Mb
scientific-6-x86_64.tar.gz (signature)2014-07-21 22:44:27210 Mb
SUSE-12.2-x86.tar.gz (signature)2014-07-21 22:04:06186 Mb
suse-12.3-x86.tar.gz (signature)2014-07-21 22:01:23190 Mb
suse-12.3-x86_64.tar.gz (signature)2014-07-21 22:02:47191 Mb
suse-13.1-x86-minimal.tar.gz (signature)2014-07-21 22:06:0955 Mb
suse-13.1-x86.tar.gz (signature)2014-07-21 22:05:43229 Mb
suse-13.1-x86_64-minimal.tar.gz (signature)2014-07-21 22:08:0356 Mb
suse-13.1-x86_64.tar.gz (signature)2014-07-21 22:07:35231 Mb
ubuntu-10.04-x86.tar.gz (signature)2014-07-21 22:19:01133 Mb
ubuntu-10.04-x86_64.tar.gz (signature)2014-07-21 22:19:52137 Mb
ubuntu-12.04-x86-minimal.tar.gz (signature)2014-07-21 22:17:0357 Mb
ubuntu-12.04-x86.tar.gz (signature)2014-07-21 22:16:38123 Mb
ubuntu-12.04-x86_64-minimal.tar.gz (signature)2014-07-21 22:18:1358 Mb
ubuntu-12.04-x86_64.tar.gz (signature)2014-07-21 22:17:50125 Mb
ubuntu-14.04-x86-minimal.tar.gz (signature)2014-07-21 22:14:1873 Mb
ubuntu-14.04-x86.tar.gz (signature)2014-07-21 22:13:48145 Mb
ubuntu-14.04-x86_64-minimal.tar.gz (signature)2014-07-21 22:15:4975 Mb
ubuntu-14.04-x86_64.tar.gz (signature)2014-07-21 22:15:17147 Mb

下载完之后

比如:下载了一个ubuntu14.04的镜像

cat ubuntu-14.04-x86_64-minimal.tar.gz  |docker import - ubuntu:14.04

然后用docker images看下:

docker images

REPOSITORY          TAG                IMAGE ID            CREATED            VIRTUAL SIZE

ubuntu              14.04              05ac7c0b9383        17 seconds ago      215.5 MB

就多了一个我们的ubuntu镜像

第三步:创建私有仓库

官方指南称最简单的办法是 docker run -p 5000:5000 registry,可我们在china

感谢CSDN,我有一个1M的腾讯云服务器,上面搭建了一个私有仓库大家可以使用docker pull 203.195.193.251:5000/registry,到我的服务器下载 速度虽然慢点,但有保证哈

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/17614.html