dockeredgedb

How to initialize EdgeDB on Docker


I'm newly with EdgeDB. I'm trying to setup EdgeDB with Docker compose but when in run edgedb project init --server-instance project --non-interactive got this error:

root@edgedb:/project# edgedb project init --server-instance project --non-interactive
Found `edgedb.toml` in /project
Initializing project...
Checking EdgeDB versions...
┌────────────────────────┬──────────────────────┐
│ Project directory      │ /project             │
│ Project config         │ /project/edgedb.toml │
│ Schema dir (non-empty) │ /project/dbschema    │
│ Installation method    │ portable package     │
│ Version                │ 5.4+427a7f2          │
│ Instance name          │ project              │
└────────────────────────┴──────────────────────┘
Version 5.4+427a7f2 is already downloaded
Initializing EdgeDB instance...
[edgedb] ---- Exception occurred: /root/.local/share/edgedb/portable/5.4/bin/pg_ctl exited with status 1:
[edgedb]     pg_ctl: cannot be run as root
[edgedb]     Please log in (using, e.g., "su") as the (unprivileged) user that will
[edgedb]     own the server process. ----
[edgedb] 
[edgedb] 1. edb.server.pgcluster.ClusterError: /root/.local/share/edgedb/portable/5.4/bin/pg_ctl exited with status 1:
[edgedb]     pg_ctl: cannot be run as root
[edgedb]     Please log in (using, e.g., "su") as the (unprivileged) user that will
[edgedb]     own the server process.
[edgedb] 
[edgedb] ---- Traceback ----
[edgedb] 
[edgedb]     /root/.local/share/edgedb/portable/5.4/bin/edgedb-server.py, line 7, in <module>
[edgedb]         > sys.exit(main())
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/click/core.py, line 1157, in __call__
[edgedb]         > return self.main(*args, **kwargs)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/click/core.py, line 1078, in main
[edgedb]         > rv = self.invoke(ctx)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/click/core.py, line 1666, in invoke
[edgedb]         > rv = super().invoke(ctx)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/click/core.py, line 1434, in invoke
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/click/core.py, line 783, in invoke
[edgedb]         > return ctx.invoke(self.callback, **ctx.params)
[edgedb]         > return __callback(*args, **kwargs)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/click/decorators.py, line 33, in new_func
[edgedb]         > return f(get_current_context(), *args, **kwargs)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/edb/server/main.py, line 778, in main
[edgedb]         > server_main(**kwargs)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/edb/server/main.py, line 756, in server_main
[edgedb]         > asyncio.run(run_server(
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/asyncio/runners.py, line 194, in run
[edgedb]         > return runner.run(main)
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/asyncio/runners.py, line 118, in run
[edgedb]         > return self._loop.run_until_complete(task)
[edgedb]     uvloop/loop.pyx, line 1517, in uvloop.loop.Loop.run_until_complete
[edgedb]         
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/edb/server/main.py, line 576, in run_server
[edgedb]         > pg_cluster_init_by_us = await cluster.ensure_initialized()
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/edb/server/pgcluster.py, line 508, in ensure_initialized
[edgedb]         > await self.init(
[edgedb]         > await _run_logged_subprocess(
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/edb/server/pgcluster.py, line 1388, in _run_logged_subprocess
[edgedb] 
[edgedb] edb.server.pgcluster.ClusterError: /root/.local/share/edgedb/portable/5.4/bin/pg_ctl exited with status 1:
[edgedb]     own the server process.
[edgedb]     Please log in (using, e.g., "su") as the (unprivileged) user that will
[edgedb]         > raise ClusterError(
[edgedb]     pg_ctl: cannot be run as root
[edgedb]     /root/.local/share/edgedb/portable/5.4/lib/python3.12/site-packages/edb/server/pgcluster.py, line 539, in init

Solution

  • You can't run edged project init inside Docker container, so:

    Option 1 If you use EdgeDB directly:

    docker exec --user edgedb onboarding-edgedb-local-ctnr edgedb --tls-security=insecure -H 0.0.0.0 migration apply
    

    Option 2 If you use your own Postgres as backend for EdgeDB:

    docker exec -it --user edgedb onboarding-edgedb-local-ctnr edgedb --tls-security=insecure --password -H 0.0.0.0 migration apply