docker私服搭建

docker可以使用阿里云的私服,也可以自己公司进行搭建,阿里云的自己看阿里云,下面主要将公司内私服搭建
1、拉取私服镜像

docker pull registry

2、启动registry

docker run -d -p 5000:5000 -v /data/myregistry/:/tmp/registry --privileged=true registry

默认情况下,仓库被创建在容器的/var/lib/registry目录下,可自行用容器卷映射,方便宿主机联调。
3、提交镜像

docker commit -m="lmytest" -a="lmy" 2c8c6b67c4e5 centos:1.0   

4、标记本地镜像

docker tag centos:1.0 192.168.236.130:5000/centos:1.0

查看本地镜像,这时可以看到标记后的镜像已经生成

[root@localhost ~]# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
192.168.236.130:5000/centos   1.0       3cf73170be02   5 minutes ago   559MB
centos                        1.0       3cf73170be02   5 minutes ago   559MB

5、推送镜像到私服

docker push 192.168.236.130:5000/centos:1.0 

如果出现如下错误:说明docker registry默认不运行http推送镜像,需要使用https

The push refers to repository [192.168.236.130:5000/centos]
Get "https://192.168.236.130:5000/v2/": http: server gave HTTP response to HTTPS client

解决方法
修改/etc/docker/daemon.json,增加 “insecure-registries”:[“192.168.236.130:5000”] 注意json格式前面有个逗号

vim /etc/docker/daemon.json 
{
  "registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"],
  "insecure-registries":["192.168.236.130:5000"]
}

重启docker

systemctl restart docker

注意重启完后,再次启动私服,然后再执行推送命令
6、查看私服中的镜像

[root@localhost ~]# curl -XGET http://192.168.236.130:5000/v2/_catalog
{"repositories":["centos"]}

这时可以看到已经上传上去;
7、下拉镜像

docker pull 192.168.236.130:5000/centos:1.0
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值