我仍然不清楚为什么我的原始代码不起作用,但是我可以将代码切换为使用Compose的v2格式,但我可以在服务之外定义卷。
这是我更新的docker-compose.yml文件:
version: '2'services: db: image: postgres:9.4 restart: always expose: - "5432" volumes: - postgres-data:/var/lib/postgresql app: build: . restart: always env_file: .env expose: - "8000" links: - db:db volumes: - static-data:/static_files web: build: docker/web restart: always ports: - "80:80" links: - app:app volumes: - static-data:/static_filesvolumes: postgres-data: driver: local static-data: driver: local
其余的配置文件保持不变。
(可能值得注意的是,在运行此新配置之前,我删除了列出的所有现有Docker卷
docker volume ls-也许这是我的实际解决方法?)



