Docker卷通过docker-compose装载了空内容 [英] Docker volume mounts with empty contents with docker-compose

查看:105
本文介绍了Docker卷通过docker-compose装载了空内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够将包含特定文件的目录挂载到docker-compose的容器中.我的在HyperV上运行的Docker.但是在我的团队中,成员无法挂载此目录.

I'm able to mount a directory with specific files to docker-compose'd containers. My Docker which runs on HyperV. But on my team members are unable to mount this directory.

使用相同的docker-compose文件.唯一的区别是我的docker在HyperV上运行,而我的团队成员在VirtualBox上运行.那么也许正是这种差异导致了问题?

The same docker-compose file is used. The only difference is my docker runs on HyperV and my team members on VirtualBox. So maybe it's this difference that causes the issue?

我考虑过使用 docker volume create ... 创建卷,但是我不明白如何将其链接到具有内容的现有目录.

I thought of creating the volume using docker volume create ... But I couldn't understand how I link it to an existing directory with content.

这是我的docker-compose.yml的代码段.任何方向都值得赞赏.

Here is a snippet of my docker-compose.yml. Any point of direction is appreciated.

version: '3.2'

services:
    service1:
        ...
        volumes:
            - type: volume
              source: ./volume
              target: /opt/volume/

推荐答案

创建一个 docker-compose.yml 文件

创建自定义路径卷并以群体模式运行您的应用程序

Create a custom path volume and run your application in swarm mode

version: '3'
services:
    app:
        image: app
        volumes:
            - data-logs:/var/wslogs

volumes:
  data-logs:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /my/host/path/logs/

这篇关于Docker卷通过docker-compose装载了空内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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