docker-archive / docker-registry

This is **DEPRECATED**! Please go to https://github.com/docker/distribution
Apache License 2.0
2.88k stars 879 forks source link

Sudo docker-registry -> OSError: [Errno 2] No such file or directory: './registry._setup_database.lock' #937

Closed alexanderfichel closed 9 years ago

alexanderfichel commented 9 years ago

I am having trouble starting the private docker registry on my ubuntu ec2 instance (I will post the problem I am having down below, first ill describe how I installed it).

I installed it the following way:

apt-get update
apt-get install python-pip
apt-get install python-dev
apt-get install python-mysqldb
apt-get install python-rsa
apt-get install libssl-dev
apt-get install liblzma-dev
apt-get install libevent1-dev
pip install docker-registry
cp /usr/local/lib/python2.7/dist-packages/config/config_sample.yml /usr/local/lib/python2.7/dist-packages/config/config.yml
mkdir /var/docker-registry

In config.yml, point to new dir for .db file and change storage path

sqlalchemy_index_database: _env:SQLALCHEMY_INDEX_DATABASE:sqlite:////var/docker-registry/docker-registry.db
storage_path: _env:STORAGE_PATH:/var/docker-registry/registry

Then I set my env variables:

export AWS_BUCKET=itmcc-docker-registry-backend \
export AWS_KEY=******************** \
export AWS_SECRET=***************************************** \
export SETTINGS_FLAVOR=prod \
export DOCKER_REGISTRY_CONFIG=/usr/local/lib/python2.7/dist-packages/config/config.yml \
export GUNICORN_ACCESS_LOG_FILE=/var/log/docker-registry/access.log \
export GUNICORN_ERROR_LOG_FILE=/var/log/docker-registry/server.log \
export GUNICORN_OPTS=[--preload]

Btw: export GUNICORN_OPTS=[--preload] was the recommended workaround according to issue: https://github.com/docker/docker-registry/issues/870

Then I run:

sudo docker-registry

And get this error:

    [2015-02-18 11:56:00 +0000] [1169] [INFO] Starting gunicorn 19.1.1
[2015-02-18 11:56:00 +0000] [1169] [INFO] Listening at: http://0.0.0.0:5000 (1169)
[2015-02-18 11:56:00 +0000] [1169] [INFO] Using worker: gevent
[2015-02-18 11:56:00 +0000] [1176] [INFO] Booting worker with pid: 1176
[2015-02-18 11:56:00 +0000] [1177] [INFO] Booting worker with pid: 1177
[2015-02-18 11:56:00 +0000] [1178] [INFO] Booting worker with pid: 1178
[2015-02-18 11:56:00 +0000] [1179] [INFO] Booting worker with pid: 1179
18/Feb/2015:11:56:02 +0000 WARNING: Cache storage disabled!
18/Feb/2015:11:56:02 +0000 WARNING: Cache storage disabled!
18/Feb/2015:11:56:02 +0000 WARNING: LRU cache disabled!
18/Feb/2015:11:56:02 +0000 WARNING: Cache storage disabled!
18/Feb/2015:11:56:02 +0000 WARNING: LRU cache disabled!
18/Feb/2015:11:56:02 +0000 WARNING: LRU cache disabled!
18/Feb/2015:11:56:02 +0000 WARNING: Cache storage disabled!
18/Feb/2015:11:56:02 +0000 WARNING: LRU cache disabled!
18/Feb/2015:11:56:02 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
18/Feb/2015:11:56:02 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
18/Feb/2015:11:56:02 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
18/Feb/2015:11:56:02 +0000 DEBUG: Will return docker-registry.drivers.file.Storage
[2015-02-18 11:56:02 +0000] [1176] [ERROR] Exception in worker process:
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'
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'
[2015-02-18 11:56:02 +0000] [1177] [ERROR] Exception in worker process:
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'
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'
[2015-02-18 11:56:03 +0000] [1178] [ERROR] Exception in worker process:
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'
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'
[2015-02-18 11:56:03 +0000] [1178] [INFO] Worker exiting (pid: 1178)
[2015-02-18 11:56:03 +0000] [1177] [INFO] Worker exiting (pid: 1177)
[2015-02-18 11:56:03 +0000] [1176] [INFO] Worker exiting (pid: 1176)
Traceback (most recent call last):
  File "/usr/local/bin/gunicorn", line 11, in <module>
    sys.exit(run())
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 74, in run
    WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 185, in run
    super(Application, self).run()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 71, in run
    Arbiter(self).run()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 196, in run
    self.halt(reason=inst.reason, exit_status=inst.exit_status)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 292, in halt
    self.stop()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 343, in stop
    time.sleep(0.1)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 209, in handle_chld
    self.reap_workers()
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 459, in reap_workers
    raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
ubuntu@ip-10-232-1-123:~$ [2015-02-18 11:56:03 +0000] [1179] [INFO] Worker exiting (pid: 1179)

No logs are generated in /var/log/docker-registry folder. Also I cannot for the life of me find how the command -> "docker-registry" is installed and where I can find it. I would really appreciate any help I can get here!

dmp42 commented 9 years ago

I would really recommend you use the container: docker run registry About the exception here, your environment vars are probably not taken into account. Put them in a script with your docker-registry launch command, and call that script instead is a solution.

alexanderfichel commented 9 years ago

Well I was trying to learn the registry, its easier without the docker container overhead, plus I used all the installation steps from the dockerfile anyway. But my question is where does this command "docker-registry" come from. Because when I run it, it tells me to set the env variables.

ubuntu@ip-10-232-1-123:/$ docker-registry -h
usage: docker-registry [-h]

run the docker-registry with gunicorn, honoring the following
environment variables:
REGISTRY_HOST: TCP host or ip to bind to; default is 0.0.0.0
REGISTRY_PORT: TCP port to bind to; default is 5000
GUNICORN_WORKERS: number of worker processes gunicorn should start
GUNICORN_GRACEFUL_TIMEOUT: timeout in seconds for graceful worker restart
GUNICORN_SILENT_TIMEOUT: timeout in seconds for restarting silent workers
GUNICORN_USER: unix user to downgrade priviledges to
GUNICORN_GROUP: unix group to downgrade priviledges to
GUNICORN_ACCESS_LOG_FILE: File to log access to
GUNICORN_ERROR_LOG_FILE: File to log errors to
GUNICORN_OPTS: extra options to pass to gunicorn

optional arguments:
  -h, --help  show this help message and exit

And here are my env variables.

$ env

GUNICORN_OPTS=[--preload]
XDG_SESSION_ID=1
TERM=xterm
SHELL=/bin/bash
DOCKER_REGISTRY_CONFIG=/usr/local/lib/python2.7/dist-packages/config/config.yml
SSH_CLIENT=10.234.68.88 1711 22
SSH_TTY=/dev/pts/0
AWS_BUCKET=itmcc-docker-registry-backend
USER=ubuntu
GUNICORN_ACCESS_LOG_FILE=/var/log/docker-registry/access.log
LS_COLORS=...
MAIL=/var/mail/ubuntu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
AWS_KEY=******************
PWD=/
LANG=en_US.UTF-8
GUNICORN_ERROR_LOG_FILE=/var/log/docker-registry/server.log
SHLVL=1
HOME=/home/ubuntu
SETTINGS_FLAVOR=prod
LOGNAME=ubuntu
SSH_CONNECTION=10.234.68.88 1711 10.232.1.123 22
LESSOPEN=| /usr/bin/lesspipe %s
AWS_SECRET=******************************
XDG_RUNTIME_DIR=/run/user/1000
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/var/log/docker-registry
dmp42 commented 9 years ago

which docker-registry should give you the location.

The output does NOT look like the official command - is this a wrapper script from your distro?

dmp42 commented 9 years ago

And because of the way you launch it (with sudo) your environment is NOT honored.

alexanderfichel commented 9 years ago

I followed the directions here (https://github.com/docker/docker-registry/blob/master/ADVANCED.md)and used: pip install docker-registry

It is definitely not any custom wrapper script, unless pip install docker-registry pulls from somewhere else other than the official docker-registry.

dmp42 commented 9 years ago

So, can you copy the output of which docker-registry? Than copy the output of cat $(which docker-registry)

dmp42 commented 9 years ago

Either way, about your issue, like suggested, make sure your environment is copied (eg: put your export in a script along with your docker-registry invocation).

alexanderfichel commented 9 years ago

Yup it was the sudo thing! Sorry I am kind of new to linux.

The output I get is:

#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'docker-registry==0.9.1','console_scripts','docker-registry'
__requires__ = 'docker-registry==0.9.1'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('docker-registry==0.9.1', 'console_scripts', 'docker-registry')()
    )