卷不按预期运行 [英] Volumes not behaving as expected

查看:72
本文介绍了卷不按预期运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试对容器使用卷时,卷的行为不符合预期。  正在创建卷但是当容器开始启动时,它会失败,因为该目录不为空。  预期的行为是
目录的内容将被复制到卷。  我有一位同事在Linux下对此进行了测试,它运行正常。

When trying to use volumes with containers the volumes do not behave as expected.  Volumes are being created but when the container begins to start it fails because the directory is not empty.  The expected behavior is that the contents of the directory would be copied to the volume.  I have had a colleague test this under Linux and it works fine.

Docker版本

PS E: \docker\windows\core> docker version

客户:

 版本:      17.03.0-ce

  API版本:  1.26

  Go version:  go1.7.5

  Git commit:  60ccb22

 内置:        Thu Mar  2 01:11:00 2017


  OS / Arch:      windows / amd64



服务器:

 版本:      17.03.0-ce

  API版本:  1.26(最低版本1.24)

  Go版本:  go1.7.5

  Git commit:  60ccb22

 内置:        Thu Mar  2 01:11:00 2017


  OS / Arch:      windows / amd64

 实验:false

PS E:\docker\windows\core> docker version
Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   60ccb22
 Built:        Thu Mar  2 01:11:00 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.24)
 Go version:   go1.7.5
 Git commit:   60ccb22
 Built:        Thu Mar  2 01:11:00 2017
 OS/Arch:      windows/amd64
 Experimental: false

Windows版本

PS E:\ docker \windows \ core> [System.Environment] :: OSVersion.Version



主要 轻微 构建 修订版

-----  ; -----  -----  --------

10    0      14393  0

PS E:\docker\windows\core> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      14393  0

Dockerfile

FROM microsoft / windowsservercore

SHELL [" powershell"," -Command"," $ ErrorActionPreference ='Continue'; $ ProgressPreference ='SilentlyContinue';"]

WORKDIR /
$
RUN New-Item -ItemType目录-Path C:\voltest

RUN New-Item -ItemType目录-Path C:\voltest \ a

RUN New-Item -ItemType目录-Path C:\voltest \b

FROM microsoft/windowsservercore
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Continue'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR /
RUN New-Item -ItemType directory -Path C:\voltest
RUN New-Item -ItemType directory -Path C:\voltest\a
RUN New-Item -ItemType directory -Path C:\voltest\b

docker-compose.yaml

docker-compose.yaml



版本:'2.1'

服务:

  voltest:

    build:。

   卷:

      - voltest:C:\ voltest

卷:

  voltest:

   司机:本地

网络:

 默认值:

   外部:

     姓名:nat

docker-compose.yaml

version: '2.1'
services:
  voltest:
    build: .
    volumes:
      - voltest:C:\voltest
volumes:
  voltest:
    driver: local
networks:
  default:
    external:
      name: nat

构建和错误




推荐答案

这是Windows平台上Docker的一个已知限制,在文档中有说明。 ( https://docs.docker.com/engine/reference/builder/#notes -about-specified-volumes


这篇关于卷不按预期运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆