我正在Windows 10上尝试将flask应用程序转换为docker flask应用程序,问题是它无法为postgres创建一个容器,它显示此错误:
Successfully tagged news_web:latest
Creating news_postgres_1 ... error
ERROR: for news_postgres_1 Cannot create container for service postgres: invalid volume specification: 'C:\Users\User\Desktop\DEV\news\pgdata:/var/lib/postgresql/data/:rw': invalid mount config for type "bind": bind source path does not exist: c:\users\user\desktop\dev\news\pgdata
这是我的docker-compose.yml文件:
version: '3.7'
services:
postgres:
restart: always
image: postgres:11.0
expose:
- "5432"
volumes:
- ./pgdata:/var/lib/postgresql/data/
web:
restart: always
build: ./news
command: ["python", "manage.py", "runserver"]
volumes:
- ./news:/usr/src/news/app
ports:
- 5000:5000
env_file:
- ./news/.env
depends_on:
- postgres
environment:
- ENV=staging
- POSTGRES_DB=newsdb
- POSTGRES_USER=postgres
- POSTGRES_HOST=postgres
- POSTGRES_PASSWORD=123123
- POSTGRES_PORT=5432
答案 0 :(得分:1)
此错误的意思是您没有正确的目录用作卷的源:pgdata
应该位于您的C:\Users\User\Desktop\DEV\news
文件夹中。