minorblog

系统环境: CentOS 7.2
192.168.11.138:docker仓库
192.168.11.211:客户端

搭建私有仓库

138上下载registry镜像: docker pull registry

下载完之后我们通过该镜像启动一个容器

1 docker run -d -p 5000:5000 --privileged=true -v /opt/registry:/tmp/registry --name=registry registry

-d 在后台执行

-p 端口映射, 开放容器的5000端口

-v /opt/registry:/tmp/registry :默认情况下,会将仓库存放于容器内的/tmp/registry目录下,指定本地目录挂载到容器
–privileged=true :CentOS7中的安全模块selinux把权限禁掉了,参数给容器加特权,不加上传镜像会报权限错误(OSError: [Errno 13] Permission denied: ‘/tmp/registry/repositories/liibrary’)或者(Received unexpected HTTP status: 500 Internal Server Error)错误

本机上传镜像

1 docker tag ubuntu:latest localhost:5000/ubuntu
2 docker push localhost:5000/ubuntu

查看仓库的镜像

curl http://localhost:5000/v2/_catalog

{"repositories":["ubuntu"]}

curl http://localhost:5000/ubuntu/tags/list

{"name":"ubuntu","tags":["latest"]}

 

然后使用docker pull从我们的私有仓库中获取ubuntu镜像,

1 docker push localhost:5000/ubuntu
2 docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
localhost:5000/ubuntu latest f975c5035748 4 days ago 112MB
registry latest d1fd7d86a825 2 months ago 33.3MB

客户端上传镜像

 

在”/etc/docker/“目录下,创建”daemon.json“文件。在文件中写入:
如果有这个文件就在时面加一条
{ "insecure-registries":["192.168.1.113:5000"] }

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-09-10
  • 2021-08-22
  • 2021-11-17
  • 2021-08-18
  • 2022-12-23
猜你喜欢
  • 2020-04-27
  • 2021-06-20
  • 2021-08-09
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案