NFS-Docker挂载NFS


Docker Server 发布

# 创建 volume
docker volume create --driver local \
    --opt type=nfs \
    --opt o=addr=111.111.3.41,rw \
    --opt device=:/root/share \
    foo33

# 查看 volume
docker volume ls
docker volume inspect foo33

# 发布服务
docker service create \
  --name test-nginx-nfs \
  --publish 84:80 \
  --mount type=volume,source=foo33,destination=/app/share \
  --replicas 3 \
  nginx

Docker Stack 发布

version: '3.8'
services:
  nginx-test5:
    image: nginx:latest
    deploy:
      mode: replicated
      replicas: 3
      restart_policy:
        condition: on-failure
    ports:
      - "88:80"
    networks:
      my-overlay-network:
        aliases:
          - nginx-test5
    volumes:
      - "foo_new:/app/share"

volumes:
  foo_new:
    driver_opts:
      type: "nfs"
      o: "addr=111.111.3.41,rw"
      device: ":/root/share"

networks:
  my-overlay-network:
    driver: overlay

启动:

docker stack deploy -c docker-compose.yml app

文章作者: 钱不寒
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 钱不寒 !
  目录