1

问题

关注 postgres docker 官方页面: https ://hub.docker.com/_/postgres

我创建了“stack.yml”,它包含:

# Use postgres/example user/password credentials
version: '3.1'

services:
  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: example

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

然后运行命令:

$ docker stack deploy -c stack.yml postgres

但是完成后,我无法打开 http://localhost:8080

管理员卡住了

它一直在“等待...”

我遵循了文档中的所有内容,并不断重试但一直失败,任何帮助将不胜感激?

更新:

usingdocker-compose正在工作,但我仍然很好奇为什么运行 withdocker stack ...不起作用

额外细节

软件版本:

Pop!_OS 20.04 LTS
Docker version 19.03.12, build 48a66213fe

这是$ docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
f0fa7f4ce6ef        postgres:latest     "docker-entrypoint.s…"   23 minutes ago      Up 23 minutes       5432/tcp            postgres_db.1.pq28sm95br3hhr92gvxpsrgwd
4a8b54019f7d        adminer:latest      "entrypoint.sh docke…"   23 minutes ago      Up 23 minutes       8080/tcp            postgres_adminer.1.kya7f232pjc4975ubj9ywa13x

这是$ docker service ls

ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
j7mxwf0rpi7g        postgres_adminer    replicated          1/1                 adminer:latest      *:8080->8080/tcp
we8izke0tb34        postgres_db         replicated          1/1                 postgres:latest 

这是docker logspostgres:

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok


Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
waiting for server to start....2020-09-08 06:21:18.981 UTC [46] LOG:  starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2020-09-08 06:21:18.982 UTC [46] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-09-08 06:21:18.994 UTC [47] LOG:  database system was shut down at 2020-09-08 06:21:18 UTC
2020-09-08 06:21:18.997 UTC [46] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

2020-09-08 06:21:19.074 UTC [46] LOG:  received fast shutdown request
waiting for server to shut down....2020-09-08 06:21:19.075 UTC [46] LOG:  aborting any active transactions
2020-09-08 06:21:19.076 UTC [46] LOG:  background worker "logical replication launcher" (PID 53) exited with exit code 1
2020-09-08 06:21:19.077 UTC [48] LOG:  shutting down
2020-09-08 06:21:19.090 UTC [46] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2020-09-08 06:21:19.186 UTC [1] LOG:  starting PostgreSQL 12.4 (Debian 12.4-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2020-09-08 06:21:19.186 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2020-09-08 06:21:19.186 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2020-09-08 06:21:19.188 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-09-08 06:21:19.216 UTC [55] LOG:  database system was shut down at 2020-09-08 06:21:19 UTC
2020-09-08 06:21:19.219 UTC [1] LOG:  database system is ready to accept connections

这是docker logs给管理员的:

[Tue Sep  8 06:21:01 2020] PHP 7.4.10 Development Server (http://[::]:8080) started
4

1 回答 1

0

使用IP地址而不是hostname

于 2020-09-11T05:31:04.887 回答