【问题标题】:Error when using `docker run` with volume使用带有卷的`docker run`时出错
【发布时间】:2022-01-17 17:17:48
【问题描述】:

我对此真的很陌生。我是程序员,不是系统管理员。 我正在尝试使用以下命令在 Windows 主机上运行 Windows Docker 容器:

docker run --name DevSQLCont -p 1433:1433 -e accept_eula=y -e sa_password=Super5ecret! tobiasfenster/mssql-server-dev-unsupported:2019-cu14 -v sqlvolume:c:\sqlvolume

导致这个错误:(对不起德语错误文本,-它说它找不到“设置文件”)

docker : docker: Error response from daemon: container cf7b3b74e3c1546d4a594b96063f5b571a56df4db5b14036f3d5d08ab90e27d1 encountered an error during hcsshim::System::CreateProcess: failure in a Windows system 
call: Das System kann die angegebene Datei nicht finden. (0x2)
In Zeile:2 Zeichen:1
+ docker run --name DevSQLCont -p 1433:1433 -e accept_eula=y -e sa_pass ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (docker: Error r...t finden. (0x2):String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail:  Provider: 00000000-0000-0000-0000-000000000000]
[Event Detail: onecore\vm\compute\management\orchestration\vmhostedcontainer\processmanagement.cpp(173)\vmcomputeagent.exe!00007FF63689A40B: (caller: 00007FF636855C8B) Exception(2) tid(394) 80070002 The system 
cannot find the file specified.
    CallContext:[\Bridge_ProcessMessage\VmHostedContainer_ExecuteProcess] 
 Provider: 00000000-0000-0000-0000-000000000000].

如果我在没有-v sqlvolume:\sqlvolume 参数的情况下执行相同操作,则容器运行良好。 由于我在互联网上找到了不同的示例,我对参数进行了一些修改,所有这些都以相同的结果结束。 - 有任何想法吗?这不应该依赖于图像中的其他设置,不是吗?

我的目标是将数据库文件保留在主机上,并将容器用作我可以按需使用的 SQL 服务。我将使用 windows 容器,因为我需要在 windows 模式下为我经常运行的其他容器运行 docker,并且我不想设置双服务系统。

p.s.:这是该卷已正确创建的证明:

C:\WINDOWS\system32> docker volume inspect sqlvolume
[
    {
        "CreatedAt": "2022-01-17T17:17:07+01:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "C:\\ProgramData\\Docker\\volumes\\sqlvolume\\_data",
        "Name": "sqlvolume",
        "Options": {},
        "Scope": "local"
    }
]

【问题讨论】:

    标签: docker docker-volume docker-for-windows


    【解决方案1】:

    您可以将 -v 替换为以下参数 --mount source=<VOLUME NAME>,target=<PATH ON CONTAINER>

    提供您喜欢的任何卷名称(区分大小写)该卷位于 \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes

    注意:由于您运行的是 Windows 容器,因此卷位置可能与上面列出的相同,也可能不同

    【讨论】:

    • Windows 卷的默认位置是 `C:\\ProgramData\\Docker\\volumes\\` 不幸的是,我在使用 --mount 参数时遇到了同样的错误(如您的示例中所示)。 - 目标值中的文件夹不应该存在于图像上,是吗?
    【解决方案2】:

    我自己找到了答案:问题不在于参数,我尝试设置音量。问题是我在图像定义之后设置它们。

    这行得通:

    docker run --name DevSQLCont -p 1433:1433 -e accept_eula=y -e sa_password=Super5ecret! -v sqlvolume:c:\sqlvolume tobiasfenster/mssql-server-dev-unsupported:2019-cu14

    这不是

    docker run --name DevSQLCont -p 1433:1433 -e accept_eula=y -e sa_password=Super5ecret! tobiasfenster/mssql-server-dev-unsupported:2019-cu14 -v sqlvolume:c:\sqlvolume

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-14
      • 1970-01-01
      • 2017-10-18
      • 2019-12-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多