企业搭建 docker 私服实例

岁酱吖の 提交于 2019-11-29 09:47:17

企业搭建docker 私服

1 创建私服

1.1 拉去镜像

[root@localhost ~]# docker pull docker.io/registry
Using default tag: latest
Trying to pull repository docker.io/library/registry ... 
latest: Pulling from docker.io/library/registry
c87736221ed0: Pull complete 
1cc8e0bb44df: Pull complete 
54d33bcb37f5: Pull complete 
e8afc091c171: Pull complete 
b4541f6d3db6: Pull complete 
Digest: sha256:8004747f1e8cd820a148fb7499d71a76d45ff66bac6a29129bfdbfdc0154d146
Status: Downloaded newer image for docker.io/registry:latest

1.2 创建容器

[root@localhost ~]# docker run -di -p 5000:5000 --name=liubijun_registry registry
6027eda46ab74bdb30ec6de362d354161a8098af84f96938c667c1326418779c



1.3 验证

http://192.168.85.198:5000/v2/_catalog

1.4 结果

在这里插入图片描述

1.5 配置私有仓库

修改daemon.json,内容:{“insecure‐registries”:[“192.168.184.135:5000”]}

”注意“ :此步用于让 docker信任私有仓库地址

[root@localhost ~]# vi /etc/docker/daemon.json
[root@localhost ~]# cat /etc/docker/daemon.json 
{"registry-mirrors":["http://docker.mirrors.ustc.edu.cn"],
"insecure-registries":["192.168.85.198:5000"]
}
[root@localhost ~]# systemctl  restart docker
[root@localhost ~]# 

1.6 手工上传镜像到私服

1)标记此镜像为私有仓库镜像

[root@localhost ~]# docker tag jdk1.8 192.168.85.198:5000/jdk1.8
[root@localhost ~]# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
jdk1.8                       latest              88a34dbcd5f0        About an hour ago   589 MB
192.168.85.198:5000/jdk1.8   latest              88a34dbcd5f0        About an hour ago   589 MB
mynginx_1.0                  latest              242f3c6e0f81        4 months ago        109 MB
docker.io/nginx              latest              27a188018e18        4 months ago        109 MB
docker.io/tomcat             latest              5a069ba3df4d        5 months ago        465 MB
docker.io/mongo              latest              b1c8142b3efc        5 months ago        410 MB
docker.io/zookeeper          latest              2a7f6fc5c8a1        5 months ago        150 MB
docker.io/redis              latest              a55fbf438dfd        5 months ago        95 MB
docker.io/mysql              latest              7bb2586065cd        5 months ago        477 MB
docker.io/centos             latest              9f38484d220f        6 months ago        202 MB
docker.io/registry           latest              f32a97de94e1        6 months ago        25.8 MB
docker.io/lwieske/java-8     latest              ac36fa5aed45        7 months ago        163 MB
rabbitmq                     management          df80af9ca0c9        13 months ago       149 MB
elasticsearch                5.6.8               6c0bdf761f3b        18 months ago       570 MB
mobz/elasticsearch-head      5                   b19a5c98e43b        2 years ago         824 MB

2)上传标记镜像

[root@localhost ~]# docker push 192.168.85.198:5000/jdk1.8
The push refers to a repository [192.168.85.198:5000/jdk1.8]
d6faa6f536ab: Pushed 
10cc74d0d651: Pushed 
d69483a6face: Pushed 
latest: digest: sha256:38b804ff9d40f52231f5ba437b55cfdd98ff6fb0235900952e3ab78d2fbc4da7 size: 949
[root@localhost ~]# 

3) 下载镜像

[root@localhost ~]# docker pull 192.168.85.198:5000/jdk1.8


1.7 测试

测试镜像是否上传到私有仓库中

在这里插入图片描述

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!