过去一周我一直在使用 Docker,认为容器的想法非常有用,但是尽管在过去 3 天里我阅读了所有内容,但我还是无法让卷映射发挥作用
get docker-compose to use my existing volume.
Docker Version: 18.03.1-ce
docker-compose version 1.21.1, build 7641a569
I created a volume using the following via a Dockerfile
# Reference SQL image
FROM microsoft/mssql-server-windows-developer
# Create directory within SQL container for database files mapped to the volume
VOLUME sqldata:c:/MSSQL
and here it shows:
C:\ProgramData\Docker\volumes>docker volume ls
local sqldata
Now I've tried probably 60+ different "solutions" based on StackOverflow and Docker forums, but none of them work. (Note despite the names below with Azure I am simply trying to get this to run locally, Azure is next hurdle)
Docker-compose.yaml:
version: '3.4'
services:
ws:
image: wsManager
container_name: azure-wcf
ports:
- "80"
depends_on:
- db
db:
image: dbimage:latest
container_name: azure-db
volumes:
- \sqldata:/mssql
# - type: volume
# source: sqldata
# target: /mssql
ports:
- "1433"
I've added a volumes section but it does not help,
volumes:
sqldata:
external:
name: sqldata
changed the - \sqldata:/mssql
to every possible slash .. . ~ whatever. Moved the file to yaml file
到 C:\ProgramData\Docker\volumes - 基本上是我的搜索结果中显示的任何建议。 dbImage 是一个 SQL Server 映像,我需要保留其中的数据,但我想知道它的魔力是什么,因为我尝试过的任何方法都不起作用。任何帮助是极大的赞赏。
我运行的是 Windows 10 Pro build 1803。
为什么这必须如此困难?
比你更了解任何知道如何使其真正发挥作用的人。
解决方案是使用以下命令引用 Windows 上的真实路径volumes: 选项如下:
sqldb:
image: sqlimage
container_name: azure-db
volumes:
- "C:\\ProgramData\\Docker\\volumes\\sqldata:c:\\mssql"
为了保留数据,我使用了以下命令:
environment:
- "sa_password=ddsql2017@@"
- "ACCEPT_EULA=Y"
- 'attach_dbs= {"dbName":"MyDb","dbFiles":"C:\\MSSQL\\MyDb.mdf","C:\\MSSQL\\MyDb.ldf"]}]'
希望这对其他人有帮助,因为我在 SO 和其他地方搜索时发现的许多示例对我不起作用,并且在 Docker 论坛中,有很多帖子说安装卷不适用于 Windows。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)