arv-v-dsm/readme.md

240 lines
7.9 KiB
Markdown
Raw Normal View History

2023-05-02 03:11:12 +07:00
<h1 align="center">Virtual DSM for Docker<br />
2023-05-02 03:05:54 +07:00
<div align="center">
2023-10-19 20:03:10 +07:00
<img src="https://github.com/vdsm/virtual-dsm/raw/master/.github/screen.jpg" title="Screenshot" style="max-width:100%;" width="432" />
2023-05-02 03:05:54 +07:00
</div>
2023-04-16 08:41:05 +07:00
<div align="center">
2019-03-14 12:25:01 +07:00
2023-05-02 02:56:33 +07:00
[![Build]][build_url]
2023-05-06 20:24:34 +07:00
[![Version]][tag_url]
[![Size]][tag_url]
2023-05-02 02:56:33 +07:00
[![Pulls]][hub_url]
2023-03-27 02:21:13 +07:00
2023-04-16 08:41:05 +07:00
</div></h1>
2023-11-23 01:16:08 +07:00
2023-04-14 02:11:15 +07:00
Virtual DSM in a docker container.
2023-04-03 05:29:32 +07:00
## Features
- Multiple disks
2023-04-12 01:36:37 +07:00
- KVM acceleration
2024-01-15 19:31:21 +07:00
- GPU pass-through
2023-04-14 23:17:12 +07:00
- Upgrades supported
2023-10-10 10:00:54 +07:00
2023-04-03 05:40:09 +07:00
## Usage
2019-03-14 12:25:01 +07:00
2023-04-12 02:56:47 +07:00
Via `docker-compose.yml`
2019-03-14 12:25:01 +07:00
```yaml
version: "3"
services:
2023-10-16 05:41:14 +07:00
dsm:
container_name: dsm
2023-10-19 20:31:23 +07:00
image: vdsm/virtual-dsm:latest
2023-10-16 05:41:14 +07:00
environment:
DISK_SIZE: "16G"
devices:
- /dev/kvm
cap_add:
2023-10-16 06:10:23 +07:00
- NET_ADMIN
2023-10-16 05:41:14 +07:00
ports:
- 5000:5000
volumes:
2023-12-17 15:37:36 +07:00
- /var/dsm:/storage
2023-10-16 05:41:14 +07:00
restart: on-failure
stop_grace_period: 2m
2019-03-14 12:25:01 +07:00
```
2023-04-03 05:38:53 +07:00
2023-04-12 02:56:47 +07:00
Via `docker run`
2023-04-03 05:38:53 +07:00
```bash
2023-10-19 20:31:23 +07:00
docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 60 vdsm/virtual-dsm:latest
2023-04-03 05:38:53 +07:00
```
2023-04-03 22:48:49 +07:00
## FAQ
2023-04-23 08:07:25 +07:00
* ### How do I change the size of the virtual disk?
2023-04-03 22:48:49 +07:00
2023-04-23 08:07:25 +07:00
To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
2023-04-03 22:48:49 +07:00
2023-05-16 02:58:33 +07:00
```yaml
2023-04-04 00:33:53 +07:00
environment:
DISK_SIZE: "128G"
2023-04-04 00:09:17 +07:00
```
2023-07-03 16:59:40 +07:00
2023-11-01 07:40:34 +07:00
This can also be used to resize the existing disk to a larger capacity without any data loss.
2023-04-03 22:48:49 +07:00
2023-04-23 08:07:25 +07:00
* ### How do I change the location of the virtual disk?
2023-04-03 23:36:05 +07:00
2023-12-17 15:37:36 +07:00
To change the location of the virtual disk, include the following bind mount in your compose file:
2023-04-04 00:09:17 +07:00
2023-05-16 02:58:33 +07:00
```yaml
2023-04-04 00:09:17 +07:00
volumes:
2023-12-17 15:37:36 +07:00
- /var/dsm:/storage
2023-04-04 00:09:17 +07:00
```
2023-12-17 15:37:36 +07:00
Replace the example path `/var/dsm` with the desired storage folder.
2023-05-07 01:40:26 +07:00
* ### How do I add multiple disks?
2023-11-28 17:50:47 +07:00
To create additional disks, modify your compose file like this:
```yaml
environment:
DISK2_SIZE: "32G"
DISK3_SIZE: "64G"
volumes:
2023-11-23 01:16:08 +07:00
- /home/example:/storage2
- /mnt/data/example:/storage3
```
* ### How do I create a growable disk?
2023-11-24 03:20:29 +07:00
2023-12-18 18:39:11 +07:00
By default, the entire capacity of the disk is reserved in advance.
2024-01-15 03:22:13 +07:00
To create a growable disk that only allocates space that is actually used, add the following environment variable:
```yaml
environment:
DISK_FMT: "qcow2"
2023-11-24 03:20:29 +07:00
```
2023-12-19 09:33:41 +07:00
Please note that this may reduce the write performance of the disk.
2023-04-19 22:29:22 +07:00
2023-05-18 23:48:39 +07:00
* ### How do I increase the amount of CPU or RAM?
2023-04-19 03:09:05 +07:00
2024-01-15 02:12:51 +07:00
By default, a single CPU core and 1 GB of RAM are allocated to the container.
2023-12-18 18:39:11 +07:00
To increase this, add the following environment variables:
2023-04-19 03:09:05 +07:00
2023-05-16 02:58:33 +07:00
```yaml
2023-04-19 03:09:05 +07:00
environment:
RAM_SIZE: "4G"
2023-10-16 05:41:14 +07:00
CPU_CORES: "4"
2023-04-19 03:09:05 +07:00
```
2023-04-23 22:53:34 +07:00
* ### How do I verify if my system supports KVM?
2023-04-22 23:11:39 +07:00
2023-04-23 08:07:25 +07:00
To verify if your system supports KVM, run the following commands:
2023-04-22 23:11:39 +07:00
2023-05-16 02:58:33 +07:00
```bash
2023-04-22 23:11:39 +07:00
sudo apt install cpu-checker
sudo kvm-ok
```
2024-01-04 11:33:30 +07:00
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check the virtualization settings in the BIOS.
2023-04-08 20:55:16 +07:00
2023-04-23 08:18:51 +07:00
* ### How do I assign an individual IP address to the container?
2023-04-08 20:55:16 +07:00
2023-05-18 23:48:39 +07:00
By default, the container uses bridge networking, which shares the IP address with the host.
2023-04-20 22:21:08 +07:00
2023-04-23 08:54:34 +07:00
If you want to assign an individual IP address to the container, you can create a macvlan network as follows:
2023-04-08 20:55:16 +07:00
2023-05-16 02:58:33 +07:00
```bash
2023-05-13 13:22:44 +07:00
docker network create -d macvlan \
2023-04-08 20:55:16 +07:00
--subnet=192.168.0.0/24 \
--gateway=192.168.0.1 \
--ip-range=192.168.0.100/28 \
2023-04-19 22:39:59 +07:00
-o parent=eth0 vdsm
2023-04-08 20:55:16 +07:00
```
2023-04-23 08:18:51 +07:00
2023-05-13 13:22:44 +07:00
Be sure to modify these values to match your local subnet.
2023-04-20 03:49:45 +07:00
2023-05-18 23:48:39 +07:00
Once you have created the network, change your compose file to look as follows:
2023-04-08 20:55:16 +07:00
2023-05-16 02:58:33 +07:00
```yaml
2023-05-16 03:23:11 +07:00
services:
2023-10-16 05:41:14 +07:00
dsm:
container_name: dsm
..<snip>..
networks:
2023-10-16 06:10:23 +07:00
vdsm:
2023-10-16 05:41:14 +07:00
ipv4_address: 192.168.0.100
2023-04-20 03:47:27 +07:00
networks:
2023-10-16 05:41:14 +07:00
vdsm:
external: true
2023-04-08 20:55:16 +07:00
```
2023-04-23 08:07:25 +07:00
2024-01-15 19:31:21 +07:00
An added benefit of this approach is that you won't have to perform any port mapping anymore, since all ports will be exposed by default.
2023-04-08 20:55:16 +07:00
2023-05-13 13:53:37 +07:00
Please note that this IP address won't be accessible from the Docker host due to the design of macvlan, which doesn't permit communication between the two. If this is a concern, you need to create a [second macvlan](https://blog.oddbit.com/post/2018-03-12-using-docker-macvlan-networks/#host-access) as a workaround.
2023-04-20 21:51:30 +07:00
2024-01-15 11:00:15 +07:00
* ### How can DSM acquire an IP address from my router?
2023-04-20 23:16:18 +07:00
2023-05-13 13:22:44 +07:00
After configuring the container for macvlan (see above), it is possible for DSM to become part of your home network by requesting an IP from your router, just like your other devices.
2023-05-07 17:34:04 +07:00
2023-05-13 13:22:44 +07:00
To enable this feature, add the following lines to your compose file:
2023-04-20 21:51:30 +07:00
2023-05-16 02:58:33 +07:00
```yaml
2023-04-20 21:51:30 +07:00
environment:
2023-10-16 05:41:14 +07:00
DHCP: "Y"
2023-04-20 21:51:30 +07:00
device_cgroup_rules:
2023-10-16 05:41:14 +07:00
- 'c *:* rwm'
2023-04-20 21:51:30 +07:00
```
2024-01-15 19:31:21 +07:00
Please note that even if you don't want DHCP, it's still recommended to enable this feature, as it prevents NAT issues and increases performance by using a `macvtap` interface. In that case, just set a static IP from the DSM control panel after you enabled this mode.
2023-05-26 04:08:20 +07:00
2024-01-15 19:31:21 +07:00
* ### How do I pass-through the GPU?
2023-04-04 00:09:17 +07:00
2024-01-15 19:31:21 +07:00
To pass-through your Intel GPU, add the following lines to your compose file:
2023-04-04 00:09:17 +07:00
2023-05-16 02:58:33 +07:00
```yaml
2023-04-04 00:33:53 +07:00
environment:
2023-11-24 03:20:29 +07:00
GPU: "Y"
devices:
- /dev/dri
2023-04-04 00:09:17 +07:00
```
2023-04-03 23:36:05 +07:00
2023-11-24 03:20:29 +07:00
This can be used to enable the facial recognition function in Synology Photos for example.
2023-04-23 08:07:25 +07:00
2024-01-15 19:31:21 +07:00
* ### How do I pass-through a disk?
2024-01-13 00:01:20 +07:00
2024-01-15 19:31:21 +07:00
When running the container inside a virtualized environment, it is possible to pass-through disk devices directly instead of binding a folder containing an image. As these devices are already backed by an image on the host, this removes an extra layer.
2024-01-13 00:01:20 +07:00
This allows for easier management and higher performance. To do so, you can add those devices to your compose file:
```yaml
environment:
DEVICE: "/dev/sda"
DEVICE2: "/dev/sdb"
devices:
- /dev/sda
- /dev/sdb
```
2024-01-15 19:31:21 +07:00
Please note that the device needs to be totally empty (without any partition tables) in order for DSM to format it into a volume. Do not supply disks containing existing data.
2024-01-13 00:01:20 +07:00
2023-11-24 03:20:29 +07:00
* ### How do I install a specific version of vDSM?
2023-10-09 07:00:03 +07:00
2024-01-13 05:19:01 +07:00
By default, version 7.2 will be installed, but if you prefer an older version, you can add its download URL to your compose file as follows:
2023-10-09 07:00:03 +07:00
```yaml
environment:
2023-11-24 03:20:29 +07:00
URL: "https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_VirtualDSM_42218.pat"
2023-10-09 07:00:03 +07:00
```
2023-10-10 12:34:44 +07:00
2023-11-24 03:20:29 +07:00
With this method, it is even possible to switch between different versions while keeping all your file data intact.
2023-05-18 23:48:39 +07:00
* ### What are the differences compared to the standard DSM?
2023-04-03 23:36:05 +07:00
2023-11-01 07:40:34 +07:00
There are only two minor differences: the Virtual Machine Manager package is not available, and Surveillance Station will not include any free licenses.
2023-05-17 12:30:55 +07:00
2023-05-21 04:05:12 +07:00
* ### Is this project legal?
2023-05-17 12:30:55 +07:00
2023-05-21 04:07:14 +07:00
Yes, this project contains only open-source code and does not distribute any copyrighted material. Neither does it try to circumvent any copyright protection measures. So under all applicable laws, this project would be considered legal.
2023-05-17 12:30:55 +07:00
2023-07-27 06:40:31 +07:00
However, by installing Synology's Virtual DSM, you must accept their end-user license agreement, which does not permit installation on non-Synology hardware. So only run this project on an official Synology NAS, as any other use will be a violation of their terms and conditions.
2023-04-03 23:36:05 +07:00
2023-04-07 23:23:01 +07:00
## Disclaimer
2023-05-18 23:48:39 +07:00
Only run this container on Synology hardware, any other use is not permitted by their EULA. The product names, logos, brands, and other trademarks referred to within this project are the property of their respective trademark holders. This project is not affiliated, sponsored, or endorsed by Synology, Inc.
2023-05-12 19:35:56 +07:00
2023-10-19 20:03:10 +07:00
[build_url]: https://github.com/vdsm/virtual-dsm/
2023-10-19 20:31:23 +07:00
[hub_url]: https://hub.docker.com/r/vdsm/virtual-dsm
[tag_url]: https://hub.docker.com/r/vdsm/virtual-dsm/tags
2023-05-12 19:35:56 +07:00
2023-10-19 20:03:10 +07:00
[Build]: https://github.com/vdsm/virtual-dsm/actions/workflows/build.yml/badge.svg
2023-10-19 20:31:23 +07:00
[Size]: https://img.shields.io/docker/image-size/vdsm/virtual-dsm/latest?color=066da5&label=size
2023-05-12 19:35:56 +07:00
[Pulls]: https://img.shields.io/docker/pulls/kroese/virtual-dsm.svg?style=flat&label=pulls&logo=docker
2023-10-19 20:31:23 +07:00
[Version]: https://img.shields.io/docker/v/vdsm/virtual-dsm/latest?arch=amd64&sort=semver&color=066da5