Я пытаюсь запустить образ докера kartoza / postgis локально на MacOS. Он отлично работает, когда я запускаю его на экземпляре Ubuntu в DigitalOcean, но когда я пытаюсь взаимодействовать с локальным контейнером, используя интерфейс командной строки psql, я получаю следующее:
Mac:~ User$ sudo psql -h localhost -U docker -p 5432 -l
psql: FATAL: role "docker" does not exist
Где docker - это имя пользователя, которое я указал при раскрутке контейнера.
Ниже приведена команда, которую я использовал для раскрутки контейнера, а также журналы из контейнера:
Mac:~ User$ docker run --name "postgis" -p 5432:5432 -e ALLOW_IP_RANGE=0.0.0.0/0 -d -t kartoza/postgis
Журналы:
Mac:~ User$ docker logs postgis
Add rule to pg_hba: 0.0.0.0/0
Add rule to pg_hba: replication user
Setup master database
2019-03-11 11:40:40.625 UTC [28] LOG: listening on IPv4 address "127.0.0.1", port 5432
2019-03-11 11:40:40.628 UTC [28] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-03-11 11:40:40.644 UTC [33] LOG: database system was shut down at 2019-02-01 14:24:17 UTC
2019-03-11 11:40:40.649 UTC [28] LOG: database system is ready to accept connections
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+---------+-----------------------
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres ready
Postgis is missing, installing now
Creating template postgis
Enabling template_postgis as a template
UPDATE 1
Loading postgis extension
CREATE EXTENSION
Enabling hstore in the template
CREATE EXTENSION
Enabling topology in the template
CREATE EXTENSION
Loading legacy sql
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE OPERATOR CLASS
Setup postgres User:Password
CREATE ROLE
Check default db exists
Create default db gis
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privilege
s
------------------+----------+----------+---------+---------+-------------------
----
gis | docker | UTF8 | C.UTF-8 | C.UTF-8 |
postgres | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
template0 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres
+
| | | | | postgres=CTc/postg
res
template1 | postgres | UTF8 | C.UTF-8 | C.UTF-8 | =c/postgres
+
| | | | | postgres=CTc/postg
res
template_postgis | postgres | UTF8 | C.UTF-8 | C.UTF-8 |
(5 rows)
2019-03-11 11:40:43.331 UTC [28] LOG: received smart shutdown request
2019-03-11 11:40:43.339 UTC [28] LOG: background worker "logical replication launcher" (PID 39) exited with exit code 1
2019-03-11 11:40:43.340 UTC [34] LOG: shutting down
2019-03-11 11:40:43.362 UTC [28] LOG: database system is shut down
/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
Postgres initialisation process completed .... restarting in foreground
2019-03-11 11:40:44.382 UTC [212] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-03-11 11:40:44.382 UTC [212] LOG: listening on IPv6 address "::", port 5432
2019-03-11 11:40:44.387 UTC [212] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-03-11 11:40:44.406 UTC [215] LOG: database system was shut down at 2019-03-11 11:40:43 UTC
2019-03-11 11:40:44.414 UTC [212] LOG: database system is ready to accept connections
Насколько я вижу, пользователь "docker" является владельцем базы данных "gis".