Mounting a single file from an NFS docker volume into a container

后端 未结 2 700
情深已故
情深已故 2021-01-26 22:58

Example (many options omitted for brevity):

version: \"3\"
volumes:
  traefik:
    driver: local
    driver_opts:
      type: nfs
      o: \"addr=192.168.1.100,s         


        
相关标签:
2条回答
  • 2021-01-26 23:32

    You cannot mount a file or sub-directory within a named volume, the source is either the named volume or a host path. NFS itself, along with most filesystems you'd mount in Linux, require you to mount an entire filesystem, not a single file, and when you get down to the inode level, this is often a really good thing.

    The options remaining that I can think of are to mount the entire directory somewhere else inside your container, and symlink to the file you want. Or to NFS mount the directory to the host and do a host mount (bind mount) to a specific file.

    However considering the example you presented, using a docker config would be my ideal solution, removing the NFS mount entirely, and getting a read only copy of the file that's automatically distributed to whichever node is running the container.

    More details on configs: https://docs.docker.com/engine/swarm/configs/

    0 讨论(0)
  • 2021-01-26 23:41

    I believe I found the issue!

    Wrong:

       volumes:
          - traefik/traefik.toml:/traefik.toml
    

    Correct:

       volumes:
          - /traefik/traefik.toml:/traefik.toml      
    

    Start the volume with "/"

    0 讨论(0)
提交回复
热议问题