vdsm / virtual-dsm

Virtual DSM in a Docker container.
MIT License
2.68k stars 358 forks source link

How can I configure SMB shares in Virtual DSM? #667

Closed Gunlance closed 4 weeks ago

Gunlance commented 7 months ago

Accessing SMB shares within a Virtual DSM running in a Docker container inside an unprivileged LXC container

Not a native English speaker, referenced other people’s code.

https://github.com/vdsm/virtual-dsm/issues/382

# ls -l /dev-104/*
crw-rw---- 1 100000 messagebus 10, 232 Mar 28 23:40 /dev-104/kvm
crw-rw---- 1 100000 messagebus 10, 238 Mar 28 23:40 /dev-104/vhost-net

/dev-104/dri:
total 0
crw-r--r-- 1 100000 100000 226,   0 Mar 28 23:40 card0
crw-r--r-- 1 100000 100000 226, 128 Mar 28 23:40 renderD128

/dev-104/net:
total 0
crw-rw-rw- 1 100000 100000 10, 200 Mar 28 23:40 tun

my lxc.conf

# lxc.config
arch: amd64
cores: 4
features: fuse=1,mount=nfs;cifs,nesting=1
hostname: lxc-ubuntu
memory: 4096
mp0: /mnt/ssd1,mp=/mnt/ssd1
mp1: /mnt/ssd1/docker_runtime,mp=/var/lib/docker
net0: name=eth0,bridge=vmbr0,firewall=1,gw=192.168.1.3,hwaddr=xx:xx:xx:xx:xx:xx,ip=192.168.1.66/24,ip6=dhcp,type=veth
onboot: 1
ostype: ubuntu
rootfs: local:104/vm-104-disk-0.raw,mountoptions=lazytime,size=16G
startup: order=2
swap: 4096
lxc.apparmor.profile: unconfined
lxc.cgroup2.devices.allow: c 10:232 rwm
lxc.cgroup2.devices.allow: c 10:238 rwm
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev-104/net/tun dev/net/tun none bind,create=file 0 0
lxc.mount.entry: /dev-104/kvm dev/kvm none bind,create=file 0 0
lxc.mount.entry: /dev-104/vhost-net dev/vhost-net none bind,create=file 0 0
lxc.mount.entry: /dev-104/dri/card0 dev/dri/card0 none bind,create=file 0 0
lxc.mount.entry: /dev-104/dri/renderD128 dev/dri/renderD128 none bind,create=file 0 0

my docker-compose.yml

version: "3.8"
networks:
  #vdsm:
  #  driver: macvlan
  #  driver_opts:
  #    parent: eth0.83
  #  ipam:
  #    config:
  #      - subnet: 192.168.1.0/24
  #        gateway: 192.168.1.1
  dsm:
    container_name: dsm
    image: vdsm/virtual-dsm
    environment:
      DISK1_SIZE: "16G"
      DISK2_SIZE: "64G"
    volumes:
      - ./dsm:/storage1
      - /mnt/ssd1/tmp:/storage2
    devices:
      - /dev/kvm
      - /dev/net/tun
      - /dev/vhost-net
      - /dev/dri
    device_cgroup_rules:
      - c *:* rwm
    cap_add:
      - NET_ADMIN
    ports:
      - 5000:5000
      - 445:445
    restart: unless-stopped
    stop_grace_period: 2m
    environment:
      DISK_FMT: "qcow2"
      RAM_SIZE: "4G"
      CPU_CORES: "4"
      GPU: "Y"
      ALLOCATE: "N"
      # DHCP: "Y"
    sysctls:
      - net.ipv4.ip_forward=1
    #networks:
    #  vdsm:
    #    ipv4_address: 192.168.1.100

The current issue is that accessing the DSM’s shared folders via SMB is not possible. [How can this be configured? Additionally, how can the network be configured to assign the DSM its own IP within the 192.168.1.0/24 subnet?

Thanks!

Gunlance commented 7 months ago

下面是给中文搜索引擎用的 The following is for Chinese search engines; English users can skip it

自己瞎弄得,但是很意外能运行起来,在lxc非特权容器中套娃了docker,再通过共享kvm再次套娃了群晖虚拟机,但是在设置共享文件出了问题,不知道怎么设置和访问

引流: PVE LXC DSM

ps1x commented 6 months ago

Personally i was never able to do it and ended up with macvlan solution, which gave me quite some pain to setup with Traefik too, but after all i managed to do it and i have ddsn access to my vdsm as well as windows shares.