简体   繁体   中英

how to connect volume to docker container in docker-compose

my docker-compose file


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. 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. 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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