解决http协议的问题:
方法一:解决HTTPS问题
安装nginx,配置HTTPS协议
方法二:修改docker的配置文件
vim /etc/default/docker增加
OPTIONS="--insecure-registry 192.168.10.249:5000"
准备配置环境:
主机名 主机IP 服务docker-images 10.0.0.5 docker 私有库库配置
10.0.0.6 docker 客户端
[root@docker-images ~]# cat /etc/RedHat-release
CentOS Linux release 7.2.1511 (Core)
[root@docker-images ~]# uname -r
3.10.0-327.el7.x86_64
[root@docker-images ~]# uname -m
x86_64
[root@docker-images ~]# uname -a
Linux docker-images 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@docker-images ~]#
开始配置(镜像库)
1、关闭防火墙和selinux
[root@docker-images ~]# systemctl stop firewalld
[root@docker-images ~]# systemctl disable firewalld #永久
[root@docker-images ~]# setenforce 0
[root@docker-images ~]# getenforce
Permissive
[root@docker-images ~]#
2、安装docker
yum install docker
[root@docker-images ~]# systemctl enable docker #加入开机自启动
[root@docker-images ~]# systemctl start docker #开启服务
3、下载本地私有库registry
[root@docker-images ~]# docker pull registry #默认下载最新版
[root@docker-images ~]# docker images #查看下载的镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest 047218491f8c 10 days ago 33.17 MB
[root@docker-images ~]#
4、基于私有仓库镜像运行容器
[root@docker-images ~]# docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry docker.io/registry
#默认仓库创建在/tmp/registry,用-v参数指定仓库存放位置
1e8b1a03013ee66034b40aee1820000a2ccf026a3b1e43606f3e4007b2a9d455
[root@docker-images ~]#
[root@docker-images ~]# docker ps #查看运行容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1e8b1a03013e docker.io/registry "/entrypoint.sh /etc/" 35 seconds ago Up 32 seconds 0.0.0.0:5000->5000/tcp goofy_mcnulty
[root@docker-images ~]#
5、访问私有仓库
[root@docker-images ~]# curl 127.0.0.1:5000/v2
<a href="https://www.linuxidc.com/v2/">Moved Permanently</a>.
[root@docker-images ~]#
#说明registry部署成功
6、为基础镜像打标签
[root@docker-images ~]# docker search docker.io/Fedora/ssh|grep docker.io/fedora/ssh
docker.io docker.io/fedora/ssh 20 [OK]
[root@docker-images ~]# docker pull docker.io/fedora/ssh #下载镜像
[root@docker-images ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest 047218491f8c 10 days ago 33.17 MB
docker.io/fedora/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
[root@docker-images ~]# docker tag docker.io/fedora/ssh 127.0.0.1:5000/ssh #打标签
[root@docker-images ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest 047218491f8c 10 days ago 33.17 MB
127.0.0.1:5000/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
docker.io/fedora/ssh latest ad6a3ff29626 4 weeks ago 396.7 MB
[root@docker-images ~]#
[root@docker-images ~]# vim /etc/sysconfig/docker
OPTIONS="--selinux-enabled --insecure-registry 10.0.0.5:5000" #定制私有仓库URL
[root@docker-images ~]# systemctl restart docker
7、提交镜像到本地私有库