我使用postgres容器作为我的微服务应用程序的一部分。这是我的dockerfile:
FROM postgres:alpine
COPY *.sh /docker-entrypoint-initdb.d/
我可以构建此图像并将其发布到我的azure图像注册表中。我也可以在我的docker stack yml文件中使用这个图像:
version: '3.4'
services:
webserver:
image: myreg.azurecr.io/webserver:latest
volumes:
- /etc/letsencrypt:/etc/letsencrypt
- /var/lib/letsencrypt:/var/lib/letsencrypt
ports:
- 80:80
- 443:443
postgres:
image: myreg.azurecr.io/postgresql:latest
environment:
POSTGRES_PASSWORD: my-super-secure-password
volumes:
- /data/postgresql:/var/lib/postgresql
- /data/postgresql/data:/var/lib/postgresql/data
....
但是当我尝试连接到这个容器时,我得到以下日志(来自这个容器)
2018-04-03 10:37:40.836 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2018-04-03 10:37:40.836 UTC [1] LOG: listening on IPv6 address "::", port 5432
2018-04-03 10:37:40.850 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/
2018-04-03 10:37:40.936 UTC [17] LOG: database system was shut down at 2018-04-03 1
2018-04-03 10:37:40.956 UTC [1] LOG: database system is ready to accept connections
2018-04-03 10:37:48.924 UTC [24] FATAL: password authentication failed for user "postgres"
2018-04-03 10:37:48.924 UTC [24] DETAIL: User "postgres" has no password assigned.
Connection matched pg_hba.conf line 95: "host all all all md5"
但是当我使用docker exec
进入此容器时,我可以看到我的密码:
$ docker exec -it 7224df929a21 bash
# printenv
PG_SHA256=3ccb4e25fe7a7ea6308dea103cac202963e6b746697366d72ec2900449a5e713
HOSTNAME=7224df929a21
TERM=xterm
PG_MAJOR=10
POSTGRES_PASSWORD=my-super-secure-password
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.utf8
SHLVL=1
HOME=/root
PG_VERSION=10.1
PGDATA=/var/lib/postgresql/data
_=/bin/printenv
我在这里做错了什么?