如何使用泊坞窗,compose.yml版 “1”

问题描述:

1运行postgress安装和:搬运工,compose.yml如何使用泊坞窗,compose.yml版 “1”

postgres96: 
    image: postgres:9.6 
    ports: 
    - "5432:5432" 
    volumes: 
    - ./Postgres/data:/var/lib/postgresql/data 
    env:  
    POSTGRES_PASSWORD: [email protected] 
    POSTGRES_USER: postgres 

2)$码头工人,组成了&

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 

虽然从pg-admin-iv在windows上测试,它显示'user postgre ss没有密码',

因此,从YML文件流是正确的,我想简单地把postgress和数据放在一边码头集装箱,所以如何实现这一目标?

我会用命名卷为,而不是托管映射卷:

postgres96: 
    image: postgres:9.6 
    ports: 
    - "5432:5432" 
    volumes: 
    - data:/var/lib/postgresql/data 
    environment:  
    POSTGRES_PASSWORD: [email protected] 
    POSTGRES_USER: postgres 

也许您的文件夹中有一个权限问题。

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

docker volume ls 

还可以使用泊坞窗,构成为:

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 

问候

+0

嗨@Carlos,感谢您的回复,我做的改变如你所说,但默认“Postgres的用户没有权限创建一个新的数据库,因此需要其他什么东西添加或遵循docker-compose.yml,假设postgress容器启动后,我们必须执行数据库操作,如创建新的数据库等... – Dhairya

+0

嗨,我从yml文件中删除了postgres_user和postgres_password,现在我可以创建新的数据库和表,但所有的数据存储在'pg_stat_tmp'目录,这是进行中的数据文件夹,所以如何交叉检查数据存储在码头容器外,新数据添加到数据库等..... ? – Dhairya

+0

你好,销毁容器'docker-compose down -v'它会破坏它,还有卷,但是命名卷。然后使用'docker-compose up -d'创建一个新的容器,你应该在那里看到你的表 –