博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos7搭建docker私有仓库
阅读量:6269 次
发布时间:2019-06-22

本文共 3077 字,大约阅读时间需要 10 分钟。

hot3.png

centos7-docker私有仓库

关闭防火墙

>systemctl stop firewalld.service  # 本次关闭>systemctl disable firewalld.service # 开机不启动

关闭本地selinux防火墙

用 getenforce 命令来验证 selinux防火墙 的状态(Enforcing:强制,permissive:宽容模式,disabled:关闭)> getenforceEnforcing> vi /etc/sysconfig/selinux 修改 SELINUX=disabled

注意:如果发生修改,想要让修改生效,请重启

install docker

如果安装的请跳过

>yum install docker>service docker start>chkconfig docker on

本地私有仓库registry

  • 下载 >docker pull registry
  • 搭建仓库 > docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry docker.io/registry
    • BUG
      • wordkey: registry._setup_database.lock
       
    Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 507, in spawn_worker worker.init_process() File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/ggevent.py", line 193, in init_process super(GeventWorker, self).init_process() File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 114, in init_process self.wsgi = self.app.wsgi() File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 66, in wsgi self.callable = self.load() File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load return self.load_wsgiapp() File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp return util.import_app(self.app_uri) File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 356, in import_app import(module) File "/usr/local/lib/python2.7/dist-packages/docker_registry/wsgi.py", line 27, in <module> from .search import * # noqa File "/usr/local/lib/python2.7/dist-packages/docker_registry/search.py", line 14, in <module> INDEX = index.load(cfg.search_backend.lower()) File "/usr/local/lib/python2.7/dist-packages/docker_registry/lib/index/init.py", line 82, in load return db.SQLAlchemyIndex() File "/usr/local/lib/python2.7/dist-packages/docker_registry/lib/index/db.py", line 86, in init self._setup_database() File "/usr/local/lib/python2.7/dist-packages/docker_registry/toolkit.py", line 330, in wrapper os.remove(lock_path) OSError: [Errno 2] No such file or directory: './registry._setup_database.lock' ``` 添加参数: -e GUNICORN_OPTS=["--preload"] docker run -d -p 5000:5000 -v /data/registry:/tmp/registry -e GUNICORN_OPTS=["--preload"] docker.io/registry
  • check 仓库 > curl 127.0.0.1:5000/v1/search {"num_results": 0, "query": "", "results": []}
  • 上传 本地库
    • 下载一个测试 镜像 > docker pull hello-world

    • 打标签 > docker tag docker.io/hello-world localhost:5000/hello-world 必须得这样写localhost:5000 or 127.0.0.1:5000/hello-world

    • 修改配置 > vi /etc/sysconfig/docker 添加如下内容: OPTIONS='--selinux-enabled --insecure-registry {registry_ip}:5000'

    • 重启docker > service docker restart

    • push images to 私有仓库 > docker push localhost:5000

    • check > curl 127.0.0.1:5000/v1/search {"num_results": 1, "query": "", "results": [{"description": "", "name": "library/hello-world"}]}

  • test (使用另外一台机)
    • 修改配置 > vi /etc/sysconfig/docker 添加如下内容: OPTIONS='--selinux-enabled --insecure-registry {registry_ip}:5000'
    • 重启
    • pull > docker pull 10.10.1.92:5000/hello-world

转载于:https://my.oschina.net/u/2362111/blog/711636

你可能感兴趣的文章
Spring 之 AOP
查看>>
软件项目管理|期末复习(二)
查看>>
直接调用VS.net2005中的配置界面
查看>>
程序员的自我修养五Windows PE/COFF
查看>>
关于字符集,编码格式,大小端的简单总结
查看>>
js string 转 int Number()
查看>>
课堂练习:ex 4-20
查看>>
20155328 2016-2017-2 《Java程序设计》 第8周学习总结
查看>>
python操作redis--string
查看>>
echarts图表初始大小问题及echarts随窗口变化自适应
查看>>
Inherits、CodeFile、CodeBehind的区别
查看>>
创建一个SimpleDlg
查看>>
使用XML生成菜单
查看>>
udp,tcp对于socket的写法
查看>>
第二周个人赛
查看>>
推断Windows版本号新方法
查看>>
2017-4-18 ADO.NET
查看>>
RSuite 一个基于 React.js 的 Web 组件库
查看>>
技术博客网址收藏
查看>>
python 金融分析学习
查看>>