簡體   English   中英

docker-compose postgresql永久本地存儲

[英]docker-compose postgresql persitent local storage

我如何在docker中設置postgresql以持久化到本地文件夾中?

version: '2'
services:
  db:
    image: postgres:9.6.1-alpine
    ports:
      - "5432:5432"
    environment:
      - POSTGRES_USER=a
      - POSTGRES_PASSWORD=a
      - POSTGRES_DB=a
    volumes:
      - /var/lib/postgresql:./postgres
volumes:
  pgdata:
    driver: local

這將不起作用並且僅產生收益

ERROR: for db  Cannot create container for service db: invalid volume spec "postgres": invalid volume specification: 'postgres': invalid mount config for type "volume": invalid mount path: 'postgres' mount path must be absolute
ERROR: Encountered errors while bringing up the project.

您需要使用絕對安裝路徑,。/ ./postgres應該更改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM