出现问题
前天用作测试的 Docker 挂掉了, 里面运行的 Registry 服务也随之停掉.
使用 docker start Registry 命令, 发现无法启动.
使用 docker logs Registry 命令查看, 发现报错:
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'
[2016-01-23 20:22:51 +0000] [12] [INFO] Worker exiting (pid: 12)
[2016-01-23 20:22:52 +0000] [14] [INFO] Worker exiting (pid: 14)
[2016-01-23 20:22:52 +0000] [19] [INFO] Worker exiting (pid: 19)
[2016-01-23 20:22:52 +0000] [13] [INFO] Worker exiting (pid: 13)
[2016-01-23 20:22:52 +0000] [1] [INFO] Shutting down: Master
错误根源在于 No such file or directory: ‘./registry._setup_database.lock’
于是百度了一下, 发现有帖子解决此问题:
http://stackoverflow.com/questions/28904121/install-local-docker-registry-on-centos-7/29291239#29291239
在此 Mark 一下.
解决方案是:
关闭 SELinux
查看 Linux 的 SELinux 配置:
/usr/sbin/sestatus -v
或
getenforce
关闭 SeLinux:
// 关闭并立即生效
setenforce 0
// 关闭并且重启后仍然生效
// vim /etc/selinux/config
修改 SELINUX=enforcing
为 SELINUX=disabled
关闭防火墙
查看防火墙状态
/etc/init.d/iptables status // 6
systemctl status iptables // 7
或者
iptables -L
关闭防火墙
/etc/init.d/iptables stop // 6
systemctl stop iptables // 7
重启 Registry
docker start Registry