【发布时间】:2020-04-27 21:08:09
【问题描述】:
如果我使用下面的docker-compose.yml 运行docker-compose up,它会成功运行,但我无法在 Windows 10 文件中的任何位置找到该卷。我签入了C:\Users\Public\Documents\Hyper-V\Virtual hard disks,但它是空的。
version: "3"
services:
database:
image: postgres:12.2
volumes:
- /var/lib/postgresql/data
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
如果我尝试使用如下所示的 Windows 路径指定卷的主机位置,则会收到有关权限的错误
version: "3"
services:
database:
image: postgres:12.2
volumes:
- c:/docker-volumes/database:/var/lib/postgresql/data
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
database_1 | The files belonging to this database system will be owned by user "postgres".
database_1 | This user must also own the server process.
database_1 |
database_1 | The database cluster will be initialized with locale "en_US.utf8".
database_1 | The default database encoding has accordingly been set to "UTF8".
database_1 | The default text search configuration will be set to "english".
database_1 |
database_1 | Data page checksums are disabled.
database_1 |
database_1 | fixing permissions on existing directory /var/lib/postgresql/data ...
ok
database_1 | creating subdirectories ... ok
database_1 | selecting dynamic shared memory implementation ... posix
database_1 | selecting default max_connections ... 20
database_1 | selecting default shared_buffers ... 400kB
database_1 | selecting default time zone ... Etc/UTC
database_1 | creating configuration files ... ok
database_1 | running bootstrap script ... 2020-04-27 21:00:29.194 UTC [81] FATAL:
data directory "/var/lib/postgresql/data" has wrong ownership
database_1 | 2020-04-27 21:00:29.194 UTC [81] HINT: The server must be started by
the user that owns the data directory.
database_1 | child process exited with exit code 1
database_1 | initdb: removing contents of data directory "/var/lib/postgresql/data"
将像这个 postgres 数据库这样的 docker 容器文件自动传输到 Windows 10 主机的最简单方法是什么?
【问题讨论】:
标签: docker docker-compose docker-volume docker-for-windows