手把手教你搭建Docker私有仓库
章节二:使用docker部署Asp.net core web应用程序
有了前面的基础,接下来的操作就比较简单了。先准备两台虚拟机,两台机器上都配好yum源,安装好docker,设置好docker加速器。
Docker客户端:192.168.1.160;Docker私有仓库服务器:192.168.1.161
1.在服务端192.168.1.161上拉取仓库镜像:registry
[root@localhost ~]# docker pull registry
2.在服务端192.168.1.161运行docker私有仓库
[root@localhost ~]# docker run -d -v /registry:/var/lib/registry -p : --restart=always --privileged=true --name registry registry:latest
如果成功执行,则表示我们的docker私有仓库搭建成功。
下面对这条命令的部分内容做下说明。
/registry表示宿主机目录,该目录如果不存在会自动创建。
docker -v 宿主机目录:容器目录
在网上看到的解释:
把宿主机的目录挂载到容器中
或者
把docker 容器中某目录的数据 加载到 宿主机的某个目录
这样做的目的是为了防止docker私有仓库这个容器被删除时,仓库里的镜像也会被删除。
3.在客户端制作镜像
以hello-world为例,先把它拉取下来
[root@localhost ~]# docker pull hello-world
给hello-world镜像打个tag,表示新的版本
[root@localhost ~]# docker tag hello-world 192.168.1.161:/hello-world:latest
4.将新的hello-world镜像上传到私有仓库
[root@localhost ~]# docker push 192.168.1.161:/hello-world:latest
发现会报以下错误:
The push refers to a repository [192.168.1.161:5000/hello-world]
Get https://192.168.1.161:5000/v1/_ping: http: server gave HTTP response to HTTPS client
原因是docker私有仓库服务器,默认是基于https传输的,所以我们需要在客户端192.168.1.160做相关设置,不使用https传输
[root@localhost ~]# vi /etc/docker/daemon.json
将下面的代码放进去保存并退出。
"insecure-registries":["192.168.1.161:5000"]
最终如下所示:
{
"registry-mirrors": ["https://njrds9qc.mirror.aliyuncs.com"],
"insecure-registries":["192.168.1.161:5000"]
}
依次执行下面两条命令,重新启动docker:
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
再次执行推送命令:
[root@localhost ~]# docker push 192.168.1.161:/hello-world:latest
5.在私有仓库192.168.1.161查看上传的镜像
[root@localhost repositories]# ls /registry/docker/registry/v2/repositories
或者在客户端执行以下命令查看:
[root@localhost ~]# curl http://192.168.1.161:5000/v2/_catalog
会输出:
{"repositories":["hello-world"]}
好,大功告成。
参考地址:
https://blog.csdn.net/mmd0308/article/details/77162004
https://www.cnblogs.com/Javame/p/7389093.html
手把手教你搭建Docker私有仓库的更多相关文章
- 一步步搭建docker私有仓库并从私有仓库中下载镜像
一步步搭建docker私有仓库 #下载镜像 docker pull registry#查看镜像 docker images #运行私有仓库,指定端口和数据卷 docker run -d -p : -v ...
- 搭建docker私有仓库
保存镜像的地方成为仓库(registry).目前有2种仓库:公共仓库和私有仓库. 最方便的是使用公共仓库上传和下载镜像,下载不需要注册,上传需要到公共仓库注册.公共仓库网站:https://hub.d ...
- windows 环境下搭建docker私有仓库
windows 环境下搭建docker私有仓库 1.在公用仓库中pull仓库镜像 docker pull regitry 2.启动仓库镜像 //-d意思是后台运行,-p是做端口映射,这里是将本地的50 ...
- Docker自学纪实(六)搭建docker私有仓库
docker的镜像仓库分两种:一种是从官方公有仓库拉取:还有就是自己搭建私有仓库.官方的镜像仓库是面对整个应用市场的:私有仓库一般用于公司内部,就是公司项目自身所需的镜像.搭建私有仓库有什么好处?私有 ...
- 03搭建docker私有仓库
搭建docker私仓,可以使用docker官方提供的registry镜像.该镜像目前有2.0,2.3和2.3.1版本.它只与1.6.0以上版本的docker兼容.搭建私仓的步骤如下: 一:无代理.无认 ...
- CentOS7搭建Docker私有仓库----Docker
有时候使用Docker Hub这样的公共仓库可能不方便,这种情况下用户可以使用registry创建一个本地仓库供私人使用,这点跟Maven的管理类似.目前Docker Registry已经升级到了v2 ...
- 搭建docker私有仓库,建立k8s集群
服务器IP角色分布 192.168.5.2 etcd server 192.168.5.2 kubernetes master 192.168.5.3 kubernetes node 192.168. ...
- 搭建docker私有仓库(https)
1.修改openssl.cnf,支持IP地址方式,HTTPS访问在Redhat7或者Centos系统中,文件所在位置是/etc/pki/tls/openssl.cnf.在其中的[ v3_ca]部分,添 ...
- 搭建Docker私有仓库&用户密码认证&web可视化界面
1.拉取镜像 docker pull hyper/docker-registry-web docker pull registry 2.安装 yum install docker-compose 3. ...
随机推荐
- C#基础学习之StreamReader和StreamWriter
StreamReader和StreamWriter操作字符的 FileStream操作字节的 //使用StreamReader读取文件 using (StreamReader sr=new Strea ...
- 十三、springboot集成定时任务(Scheduling Tasks)
定时任务(Scheduling Tasks) 在springboot创建定时任务比较简单,只需2步: 1.在程序的入口加上@EnableScheduling注解. 2.在定时方法上加@Schedule ...
- Mac 升级一次,php 就崩溃一次,有味,苹果....
Mac升级系统macOS Sierra后PHP不编译 Mac下搭建PHP开发环境(Apache+PHP+MySQL+phpMyAdmin),当Mac 从OS 10.11升级至macOS Sierra( ...
- angular4.0和angularJS、react.js、vue.js的简单比较
angularJS特性 模板功能强大丰富(数据绑定大大减少了代码量) 比较完善的前端MVC框架(只要学习这个框架,按照规定往里面填东西就可以完成前端几乎所有的的问题) 引入了Java的一些概念 ang ...
- sizeof求结构体大小
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- GreenPlum学习笔记:create or replace function创建函数
原始表数据如下: 需求:现要求按分号“;”将rate_item列进行分割后插入到新的数据表中. CREATE OR REPLACE FUNCTION fun_gp_test_xxx_20181026( ...
- Visual Studio 2017各版本安装包离线下载
关于Visual Studio 2017各版本安装包离线下载.更新和安装的方法以及通过已下载版本减少下载量的办法 微软最近发布了正式版Visual Studio 2017并公开了其下载方式,不过由于V ...
- Salt 与Salt API配置
1.安装 [root@localhost yum.repos.d]# cat /etc/yum.repos.d/salt.repo [saltstack-repo] name=SaltStack re ...
- thinkphp和ueditor自定义后台处理方法整合
先了解一下ueditor后台请求参数与返回参数格式规范: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 ...
- Android Studio奇技淫巧
No1: Ctrl+E:显示最近浏览过的文件 Ctrl+Shift+E:显示最近编辑过的文件 Ctrl+Tab:切换最近编辑过的文件 No2: 条件断点:断点右键 No3: 全局断点 这样只要碰到空指 ...