I'm using the pgadmin4 docker image from https://hub.docker.com/r/dpage/pgadmin4/, which says to get help using this mailing list.
I'd like to use the docker container and persist the data such that I don't have to add my connection info to Postgres every time I restart it. How can I do this?
Here's a more explicit list of what I'm doing:
1) Run the image as directed:
docker run -p 5050:80 \
-e "PGADMIN_DEFAULT_EMAIL=user@xxxxxxxxxx" \
-e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" \
-d dpage/pgadmin4
2) Visit http://localhost:5050
3) I'm asked to login, which I do using those environment variables, which works
4) I see the pgAdmin website interface, and I must choose "Add New Server" to access my server, and input my host, port, username, password, every time. I don't want to repeat this. I'd like the connection information to remain.
There are instructions on that same https://hub.docker.com/r/dpage/pgadmin4/ page that suggest to use this line as part of the docker command:
-v "/private/var/lib/pgadmin:/var/lib/pgadmin" \
However, if I do that, here's what happens:
1) Run the image as directed:
docker run -p 5050:80 \
-e "PGADMIN_DEFAULT_EMAIL=user@xxxxxxxxxx" \
-e "PGADMIN_DEFAULT_PASSWORD=SuperSecret" \
-d dpage/pgadmin4
2) Visit http://localhost:5050
3) I'm shown an error: Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
I finally figured out how to see the output of the docker logs to see what was going on. It was complaining it had no access to /var/lib/pgadmin/sessions, a directory which didn't exist. After I created it, and refreshed my browser, the logs showed an error about the /var/lib/pgadmin/storage directory not existing. Progress! So I created that one manually. But now I'm stuck. Obviously I don't want to do this forever... I need to give some permissions so it can do what it needs. Here's the error message I'm left with when I tail/follow the docker logs:
OperationalError: (sqlite3.OperationalError) unable to open database file
mod_wsgi (pid=10): Target WSGI script '/var/www/pgadmin/pgAdmin4.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=10): Exception occurred processing WSGI script '/var/www/pgadmin/pgAdmin4.wsgi'.
Traceback (most recent call last):
File "/var/www/pgadmin/pgAdmin4.wsgi", line 36, in <module>
from pgAdmin4 import app as application
File "/var/www/pgadmin/pgAdmin4.py", line 67, in <module>
app = create_app()
File "/var/www/pgadmin/pgadmin/__init__.py", line 306, in create_app
db_upgrade(app)
File "/var/www/pgadmin/pgadmin/setup/db_upgrade.py", line 25, in db_upgrade
flask_migrate.upgrade(migration_folder)
File "/usr/lib/python2.7/site-packages/flask_migrate/__init__.py", line 244, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/usr/lib/python2.7/site-packages/alembic/command.py", line 254, in upgrade
script.run_env()
File "/usr/lib/python2.7/site-packages/alembic/script/base.py", line 425, in run_env
util.load_python_file(self.dir, 'env.py')
File "/usr/lib/python2.7/site-packages/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/usr/lib/python2.7/site-packages/alembic/util/compat.py", line 141, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "/var/www/pgadmin/pgadmin/setup/../../migrations/env.py", line 94, in <module>
run_migrations_online()
File "/var/www/pgadmin/pgadmin/setup/../../migrations/env.py", line 79, in run_migrations_online
connection = engine.connect()
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2018, in connect
return self._connection_cls(self, **kwargs)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 72, in __init__
if connection is not None else engine.raw_connection()
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2104, in raw_connection
self.pool.unique_connection, _connection)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2078, in _wrap_pool_connect
e, dialect, self)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1405, in _handle_dbapi_exception_noconnection
exc_info
File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 2074, in _wrap_pool_connect
return fn()
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 318, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 713, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 480, in checkout
rec = pool._do_get()
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 1151, in _do_get
return self._create_connection()
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 323, in _create_connection
return _ConnectionRecord(self)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 449, in __init__
self.connection = self.__connect()
File "/usr/lib64/python2.7/site-packages/sqlalchemy/pool.py", line 607, in __connect
connection = self.__pool._invoke_creator(self)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 97, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 385, in connect
return self.dbapi.connect(*cargs, **cparams)
OperationalError: (sqlite3.OperationalError) unable to open database file
Any ideas?
Thanks!
Ty