【问题标题】:Kartoza postgis docker image: Psql says role does not existKartoza postgis docker image:Psql说角色不存在
【发布时间】:2019-03-11 11:55:25
【问题描述】:

我正在尝试在 MacOS 上本地运行 docker 映像 kartoza/postgis。当我在 DigitalOcean 上的 Ubuntu 实例上运行它时,它运行良好,但是当我尝试使用 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”的所有者。

【问题讨论】:

    标签: docker postgis


    【解决方案1】:

    你能设置数据库“gis”吗:

    psql -d gis -U username -h localhost
    

    然后你就可以输入你的密码了。

    【讨论】:

      猜你喜欢
      • 2021-10-11
      • 2019-06-08
      • 1970-01-01
      • 2018-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-23
      • 1970-01-01
      相关资源
      最近更新 更多