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