2

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和數據放在一邊碼頭集裝箱,所以如何實現這一目標?

回答

2

我會用命名卷爲,而不是託管映射卷:

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'創建一個新的容器,你應該在那裏看到你的表 –