我如何才能只使用 docker 群的文件挂载卷?

How i can mount volume with only file for docker swarm?

我需要一些帮助来仅挂载文件卷。

我已经用 docker-netshare 测试了 nfs 方法,但它只适用于文件夹。

我用挂载文件编写文件,但不起作用:

version: "3.7"

services:
  web:
    image: nginx
    ports:
      - 80:80
    volumes:
      - nginx.vol:/usr/share/nginx/html/index.html
    deploy:
      placement:
        constraints: [node.role == manager]

volumes:
  nginx.vol:
    driver: nfs
    driver_opts:
      share: 192.168.1.13:/nginx_web/index.html

当我 运行 命令挂载文件时出现错误:

docker run -i -t --volume-driver=nfs -v 192.168.1.13/config/traefik.toml:/root/test.toml alpine /bin/sh
docker: Error response from daemon: error while mounting volume '': VolumeDriver.Mount: exit status 32

无论如何谢谢你的帮助:)

version: '3.6'

services:
  default:
    image: traefik:1.7.6
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    configs:
      - source: traefik_config
        target: /etc/traefik/traefik.toml
    networks:
      default:
        aliases:
          - test.app
          - www.test.app
          - pma.test.app
          - monitor.test.app
    deploy:
      placement:
        constraints: [node.role != manager]
    labels:
      traefik.enable: 'true'
      traefik.frontend.rule: 'Host: monitor.test.app'
      traefik.port: 8080

configs:
  traefik_config:
    file: ../config/traefik.toml

使用对我有用的配置 谢谢大家:)