问题描述
我在 Windows 中安装了我的 docker.我正在尝试安装 this 应用程序.它给了我以下 docker-compose.yml 文件:
I have my docker installed in Windows. I am trying to install this application. It has given me the following docker-compose.yml file:
version: '2'
services:
web:
build:
context: .
dockerfile: Dockerfile-nginx
ports:
- "8085:80"
networks:
- attendizenet
volumes:
- .:/usr/share/nginx/html/attendize
depends_on:
- php
php:
build:
context: .
dockerfile: Dockerfile-php
depends_on:
- db
- maildev
- redis
volumes:
- .:/usr/share/nginx/html/attendize
networks:
- attendizenet
php-worker:
build:
context: .
dockerfile: Dockerfile-php
depends_on:
- db
- maildev
- redis
volumes:
- .:/usr/share/nginx/html/attendize
command: php artisan queue:work --daemon
networks:
- attendizenet
db:
image: postgres
environment:
- POSTGRES_USER=attendize
- POSTGRES_PASSWORD=attendize
- POSTGRES_DB=attendize
ports:
- "5433:5432"
volumes:
- ./docker/pgdata:/var/lib/postgresql/data
networks:
- attendizenet
maildev:
image: djfarrelly/maildev
ports:
- "1080:80"
networks:
- attendizenet
redis:
image: redis
networks:
- attendizenet
networks:
attendizenet:
driver: bridge
安装一切顺利,但是PostgreSQL容器启动一会就停止了,报错如下.
All the installation goes well, but the PostgreSQL container stops after starting for a moment giving following error.
2018-03-07 08:24:47.927 UTC [1] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
2018-03-07 08:24:47.927 UTC [1] HINT: The server must be started by the user that owns the data directory
来自 Docker Hub 的一个简单的 PostgreSQL 容器运行顺利,但是当我们尝试将卷附加到容器时出现错误.
A simple PostgreSQL container from Docker Hub works smoothly, but the error occurs when we try to attach a volume to the container.
我是 docker 新手,所以请忽略错误的术语使用.
I am new to docker, so please ignore usage of terms wrongly.
推荐答案
这是 Windows 上 Postgres Docker 映像的记录问题 [1][2][3][4].目前,似乎没有一种方法可以将 Windows 目录正确安装为卷.您可以改为使用持久的 Docker 卷,例如:
This is a documented problem with the Postgres Docker image on Windows [1][2][3][4]. Currently, there doesn't appear to be a way to correctly mount Windows directories as volumes. You could instead use a persistent Docker volume, for example:
db:
image: postgres
environment:
- POSTGRES_USER=attendize
- POSTGRES_PASSWORD=attendize
- POSTGRES_DB=attendize
ports:
- "5433:5432"
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- attendizenet
volumes:
pgdata:
其他无效的事情:
- 将 PGDATA 设置为子目录(参见 PGDATA 设置)
environment:
- PGDATA=/var/lib/postgresql/data/mnt
volumes:
- ./pgdata:/var/lib/postgresql/data
- 使用绑定挂载 (docker-compose 3.2)
volumes:
- type: bind
source: ./pgdata
target: /var/lib/postgresql/data
- 以 POSTGRES_USER=root 身份运行
更多信息:
GitHub
Docker 论坛
这篇关于在 Windows 10 中执行时,Docker 容器关闭并给出“数据目录所有权错误"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!