服务X从Y安装卷,而不是服务或容器的名称 [英] Service X mounts volumes from Y, which is not the name of a service or container

查看:152
本文介绍了服务X从Y安装卷,而不是服务或容器的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用docker-compose我试图创建一个共享卷,我的两个服务都可以使用它。我在我的 docker-compose.yml

Using docker-compose I'm attempting to create a shared volume that two of my services can both use. I have the following in my docker-compose.yml

version: '2'
volumes:
  bundler:
    driver: local
sidekiq:
  build: .
  volumes_from:
    - bundler:/.bundle
web:
  build: .
  volumes_from:
    - bundler:/.bundle

工作并给我:


错误:服务sidekiq从bundler安装卷,而不是服务或容器的名称

ERROR: Service "sidekiq" mounts volumes from "bundler", which is not the name of a service or container.

使用docker-compose做什么正确的方法?

What is the correct way of doing this using docker-compose?

推荐答案

我认为你在这里混合了两个概念。

I think you mixed two concepts here.


  • volumes_from 当一个容器有一些卷(装载或不装载)应用于存储时使用。然后,您可以通过引用所谓的 data-only-container volumes_from 来指定一个容器或(撰写)服务名称。另一方面,

  • volumes_from is used when one container has some volumes (mounted or not) that should be used for storage. You can then use this container's volumes by referencing the so called data-only-container with volumes_from which must point to a container or (compose) service name.

用于引用本地文件夹或命名卷。一个命名的卷然后必须在编译文件的顶级条目中声明。

volumes on the other hand is used to reference either a local folder or a named volume. A named volume then must be declared in the top level entry volumes of the compose file as you already did.

所以在你的情况下,从 volumes_from 之间的切换做伎俩有关详细信息,请参阅参考文档: https://docs.docker .com / compose / compose-file /#/ volumes-volume-driver

So in your case, a switch from volumes_from to volumes should do the trick. Please see the reference docs for details: https://docs.docker.com/compose/compose-file/#/volumes-volume-driver

这篇关于服务X从Y安装卷,而不是服务或容器的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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