简体   繁体   English

Docker组成了越来越多的空卷

[英]Docker compose mounting empty volumes

Expected behavior 预期行为

docker-compose up -d should properly mount the volumes docker-compose up -d应该正确安装卷

Actual behavior 实际行为

Suddenly (it worked perfectly two days ago, didn't install anything nor updated OS), the volumes are no longer being mounted. 突然(两天前运行良好,没有安装任何东西,也没有更新操作系统),不再装载卷。 Don't see any error message, only the container logs complaining that command can't find the file (because the "empty" volume overrides the container's copied files). 没有看到任何错误消息,只有容器日志抱怨命令找不到该文件(因为“空”卷将覆盖该容器的复制文件)。

If I remove ./service:/home/node/api volume, then docker uses the files in the container and everything works fine. 如果删除./service:/home/node/api卷,则./service:/home/node/api使用容器中的文件,并且一切正常。

Information 信息

  • Docker version 18.03.0-ce, build 0520e24302 (Docker toolbox / boot2docker / virtualbox 5.2.12) Docker版本18.03.0-ce,内部版本0520e24302(Docker工具箱/ boot2docker / virtualbox 5.2.12)
  • docker-compose version 1.20.1, build 5d8c71b2 docker-compose版本1.20.1,内部版本5d8c71b2
  • Windows 7 x64 Windows 7 x64
  • Virtual box sharing folder.jpg 虚拟盒子共享文件夹.jpg

Already tried removing the docker machine from virtualbox and creating it again, pruning all volumes / images and containers. 已经尝试从virtualbox中删除docker机器并再次创建它,修剪所有卷/图像和容器。 Even reinstalling Docker Toolbox, but issue persist. 即使重新安装Docker Toolbox,问题仍然存在。

Everything is ran with administrator rights. 一切都以管理员权限运行。

More info 更多信息

docker-compose config outputs docker-compose config输出

services:
  api:
    build:
      context: C:\users\fede\documents\test\service
    container_name: api
    ports:
    - 3000:3000/tcp
    volumes:
    - /c/users/fede/documents/test/service:/home/node/api:rw
version: '3.0'

$ docker inspect api outputs: https://pastebin.com/1zQ3vjFi $ docker inspect api输出: https : //pastebin.com/1zQ3vjFi

Files

I've simplified a sample app in order to make debug faster, you can see it here: https://github.com/Frondor/simple-node-app 为了简化调试,我简化了一个示例应用程序,您可以在此处查看: https : //github.com/Frondor/simple-node-app

I'm pretty new at docker, but if there's something else I can provide in order to start using docker locally again, just ask in the comments. 我在Docker方面还很陌生,但是如果我还可以提供其他内容以便再次在本地使用docker,请在评论中提问。 But honestly, this started happening from one day to another without doing any changes to the system. 但老实说,这是从一天到另一天开始发生的,没有对系统进行任何更改。 No anti-virus involved. 不涉及防病毒。

For future reference, I finally found the reason why this started happening "suddenly". 为了将来参考,我终于找到了这种情况突然发生的原因。 It has to do with the command line and relative paths of volumes not honoring the uppercase letters. 它与命令行和卷的相对路径无关,不遵守大写字母。

这个

Notice the same path, but displayed diferently? 注意相同的路径,但显示方式不同吗? That's product of my inexperience. 那是我经验不足的产物。

The first one works perfectly, and the VM maps the working directory to the shared volume without any problem. 第一个完美运行,并且VM毫无问题地将工作目录映射到共享卷。 I guess it has to do with C:\\Users\\Fede having uppercase letters, which the second path doesn't honor. 我想这与C:\\Users\\Fede具有大写字母有关,第二条路径不适用。

So doing cd $HOME takes me to the ~ (home) path as seen here: 因此,执行cd $HOME将我带到~ (home)路径,如下所示:

在此处输入图片说明

And now the terminal path is properly set to start mapping the host volume correctly. 现在,正确设置了终端路径,以开始正确映射主机卷。

$ docker-compose config

services:
  api:
    build:
      context: C:\Users\Fede\documents\test\service
    container_name: api
    ports:
    - 3000:3000/tcp
    volumes:
    - /c/Users/Fede/documents/test/service:/home/node/api:rw
version: '3.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM