简体   繁体   English

如何将卷连接到 docker-compose 中的 docker 容器

[英]how to connect volume to docker container in docker-compose

my docker-compose file我的 docker-compose 文件


services:
  irc:
    image: inspircd/inspircd-docker
    container_name: irc
    volumes: 
        - ./configs:/inspircd/configs


  app:
    build: ./tor
    container_name: tor
    ports: 
     - 443:443
     - 9001:9001
     - 9030:9030
    links: 
     - irc
    depends_on: 
        - irc

volumes: 
  irc_conf:
    driver: local
    driver_opts: 
      o: bind
      type: none
      device: /home/advaithm/irc_docker/configs

I don't understand how to mount my configs folder.我不明白如何挂载我的 configs 文件夹。 can someone explain how the correct way to mount them is.有人可以解释安装它们的正确方法是什么。 i need to mount configs at /home/advaithm/irc_docker/configs to /inspircd/configs in the container.我需要将 /home/advaithm/irc_docker/configs 中的配置挂载到容器中的 /inspircd/configs 中。 with just docker i would use -v /home/advaithm/irc_docker/configs:/inspircd/configs i would like to no the equivalent in the docker-compose.yml只有 docker 我会使用-v /home/advaithm/irc_docker/configs:/inspircd/configs我不想在 docker-compose.yml

Just change (host volume):只需更改(主机音量):

volumes: 
    - ./configs:/inspircd/configs

By (named volume):通过(命名卷):

volumes: 
    - irc_conf:/inspircd/configs

Named volumes can be referred to by specific names .命名卷可以通过特定名称来引用。 You have created the volume by name when you defined it at the bottom.当您在底部定义卷时,您已经按名称创建了卷。

However, you didn't mount it.但是,您没有安装它。

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

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