如何使用docker-compose.yml版本安装和运行postgress" 1"

时间:2016-11-15 17:50:33

标签: postgresql docker docker-compose postgresql-9.4 docker-machine

1:docker-compose.yml

postgres96:
  image: postgres:9.6
  ports:
    - "5432:5432"
  volumes:
    - ./Postgres/data:/var/lib/postgresql/data
  env:    
    POSTGRES_PASSWORD: admin@123
    POSTGRES_USER: postgres

2) $ docker-compose up&

postgres96_1      | LOG:  database system was not properly shut down; automatic recovery in progress
postgres96_1      | LOG:  invalid record length at 0/1570D50: wanted 24, got 0
postgres96_1      | LOG:  redo is not required
postgres96_1      | LOG:  MultiXact member wraparound protections are now enabled
postgres96_1      | LOG:  database system is ready to accept connections
postgres96_1      | LOG:  autovacuum launcher started

但是在Windows上的 pg-admin-iv 测试时,它显示'用户postgress没有密码'

来自YML文件的流量是正确的,我想简单地将postgress放到一边,并将数据放在一边的docker-container,那么如何实现呢?

1 个答案:

答案 0 :(得分:3)

我会使用命名卷而不是托管的映射卷:

postgres96:
  image: postgres:9.6
  ports:
    - "5432:5432"
  volumes:
    - data:/var/lib/postgresql/data
  environment:    
    POSTGRES_PASSWORD: admin@123
    POSTGRES_USER: postgres

您的文件夹中可能存在权限问题。

您的数据保存在容器外的卷中。然后检查:

docker volume ls

也使用docker-compose as:

docker-compose up -d

而不是&

docker-compose logs -f

有关详细信息,这是我日志的最后一部分:

postgres96_1  | PostgreSQL init process complete; ready for start up.
postgres96_1  |
postgres96_1  | LOG:  database system was shut down at 2016-11-14 21:05:51 UTC
postgres96_1  | LOG:  MultiXact member wraparound protections are now enabled
postgres96_1  | LOG:  database system is ready to accept connections
postgres96_1  | LOG:  autovacuum launcher started
postgres96_1  | LOG:  incomplete startup packet

此致