2023-04-16 08:41:05 +07:00
< h1 align = "center" > Virtual DSM for Docker
2023-04-16 08:50:57 +07:00
< br / >
2023-04-16 08:41:05 +07:00
< p align = "center" >
< img src = "https://github.com/kroese/virtual-dsm/raw/master/.github/screen.jpg" title = "Screenshot" style = "max-width:100%;" width = "432" / >
< / p >
< div align = "center" >
2019-03-14 12:25:01 +07:00
2023-03-28 23:54:04 +07:00
[![build_img]][build_url]
2023-03-28 23:52:01 +07:00
[![gh_last_release_svg]][dsm-docker-hub]
[![Docker Image Size]][dsm-docker-hub]
2023-03-27 02:21:13 +07:00
[![Docker Pulls Count]][dsm-docker-hub]
2023-03-28 23:54:04 +07:00
[build_url]: https://github.com/kroese/virtual-dsm/actions
2023-03-27 02:21:13 +07:00
[dsm-docker-hub]: https://hub.docker.com/r/kroese/virtual-dsm
2023-04-03 19:14:15 +07:00
[build_img]: https://github.com/kroese/virtual-dsm/actions/workflows/build.yml/badge.svg
2023-03-28 23:52:01 +07:00
[Docker Image Size]: https://img.shields.io/docker/image-size/kroese/virtual-dsm/latest
[Docker Pulls Count]: https://img.shields.io/docker/pulls/kroese/virtual-dsm.svg?style=flat
[gh_last_release_svg]: https://img.shields.io/docker/v/kroese/virtual-dsm?arch=amd64& sort=date
2019-03-18 04:44:21 +07:00
2023-04-16 08:41:05 +07:00
< / div > < / h1 >
2023-04-14 02:11:15 +07:00
Virtual DSM in a docker container.
2023-04-03 05:29:32 +07:00
## Features
2023-04-12 01:36:37 +07:00
- KVM acceleration
- Graceful shutdown
2023-04-14 23:17:12 +07:00
- Upgrades supported
2019-03-14 12:25:01 +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-04-13 08:18:14 +07:00
dsm:
2023-03-30 08:22:36 +07:00
container_name: dsm
2023-03-27 01:37:18 +07:00
image: kroese/virtual-dsm:latest
2023-03-28 10:22:02 +07:00
environment:
DISK_SIZE: "16G"
2019-03-14 12:25:01 +07:00
devices:
- /dev/kvm
2023-04-04 02:26:18 +07:00
cap_add:
- NET_ADMIN
2023-03-27 01:37:18 +07:00
ports:
- 5000:5000
2023-03-29 00:30:42 +07:00
restart: on-failure
2023-04-13 21:09:51 +07:00
stop_grace_period: 1m
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-04-19 03:09:05 +07:00
docker run -it --rm -p 5000:5000 --device=/dev/kvm --cap-add NET_ADMIN --stop-timeout 60 kroese/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-04-04 00:09:17 +07:00
```
2023-04-04 00:33:53 +07:00
environment:
2023-04-12 01:37:55 +07:00
DISK_SIZE: "16G"
2023-04-04 00:09:17 +07:00
```
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-04-23 08:07:25 +07:00
To change the virtual disk's location from the default docker volume, include the following bind mount in your compose file and replace the path `/home/user/data` with the desired storage folder:
2023-04-04 00:09:17 +07:00
```
volumes:
2023-04-12 01:37:55 +07:00
- /home/user/data:/storage
2023-04-04 00:09:17 +07:00
```
2023-04-23 08:09:14 +07:00
* ### How do I change the space reserved by the virtual disk?
2023-04-19 22:29:22 +07:00
2023-04-23 08:07:25 +07:00
By default, the entire disk space is reserved in advance. To reserve only the space actually used by the disk, add the following environment variable to your compose file:
2023-04-19 22:29:22 +07:00
```
environment:
ALLOCATE: "N"
```
2023-04-23 08:07:25 +07:00
Keep in mind that this doesn't affect any existing disks, and that it may impact performance as the image file will need to grow each time new data is added.
2023-04-19 22:29:22 +07:00
2023-04-23 08:07:25 +07:00
* ### How can I increase the allocated amount of CPU/RAM?
2023-04-19 03:09:05 +07:00
2023-04-23 08:07:25 +07:00
By default, a single core and 512MB of RAM is allocated to the container. To increase this, add the following environment variables:
2023-04-19 03:09:05 +07:00
```
environment:
CPU_CORES: "4"
RAM_SIZE: "2048M"
```
2023-04-23 08:07:25 +07:00
* ### How can 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
```
sudo apt install cpu-checker
sudo kvm-ok
```
2023-04-23 08:07:25 +07:00
If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check your BIOS settings.
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-04-23 08:07:25 +07:00
By default the container uses bridge networking, and uses the same IP address as the docker host.
2023-04-20 22:21:08 +07:00
2023-04-23 08:18:51 +07:00
If you want to assign a unique IP address to the container, you can create a macvlan network by running the following command:
2023-04-08 20:55:16 +07:00
```
$ docker network create -d macvlan \
--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-04-23 08:07:25 +07:00
Be sure to modify the values to match your local subnet.
2023-04-20 03:49:45 +07:00
2023-04-23 08:07:25 +07:00
Once you have created the network, modify the container's configuration in your compose file as follows:
2023-04-08 20:55:16 +07:00
```
2023-04-20 03:47:27 +07:00
networks:
vdsm:
ipv4_address: 192.168.0.100
```
2023-04-23 08:07:25 +07:00
Finally, add the network to the bottom of your compose file:
2023-04-20 03:47:27 +07:00
```
networks:
2023-04-20 03:49:45 +07:00
vdsm:
2023-04-20 03:47:27 +07:00
external: true
2023-04-08 20:55:16 +07:00
```
2023-04-23 08:07:25 +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-04-23 08:07:25 +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, there are some solutions available, but they go beyond the scope of this FAQ.
2023-04-20 21:51:30 +07:00
2023-04-23 08:07:25 +07:00
* ### How can the container acquire an IP address via DHCP?
2023-04-20 23:16:18 +07:00
2023-04-23 08:07:25 +07:00
After configuring the container for macvlan (see above), add the following lines to your compose file to enable DHCP:
2023-04-20 21:51:30 +07:00
```
environment:
DHCP: "Y"
devices:
- /dev/vhost-net
device_cgroup_rules:
- 'c 510:* rwm'
```
2023-04-23 08:18:51 +07:00
Please note that the exact `cgroup` rule number may vary depending on your system, but the log output will indicate the correct number in case of an error.
2023-04-20 21:51:30 +07:00
2023-04-23 08:07:25 +07:00
* ### How do I install a specific version of vDSM?
2023-04-04 00:09:17 +07:00
2023-04-23 08:07:25 +07:00
The default installation of vDSM is version 7.2, but if you prefer an older version, you can add its URL to your compose file:
2023-04-04 00:09:17 +07:00
```
2023-04-04 00:33:53 +07:00
environment:
2023-04-16 00:08:16 +07:00
URL: "https://global.synologydownload.com/download/DSM/release/7.1.1/42962-1/DSM_VirtualDSM_42962.pat"
2023-04-04 00:09:17 +07:00
```
2023-04-03 23:36:05 +07:00
2023-04-23 08:07:25 +07:00
With this method, you can switch between different versions while keeping your file data.
* ### What are the differences compared to standard DSM?
2023-04-03 23:36:05 +07:00
2023-04-23 08:07:25 +07:00
There are only three minor differences: the Virtual Machine Manager package is not provided, Surveillance Station doesn't include any free licenses, and logging in to your Synology account is not supported.
2023-04-03 23:36:05 +07:00
2023-04-04 23:05:47 +07:00
## Acknowledgments
2023-04-07 00:12:53 +07:00
Based on an [article ](https://jxcn.org/2022/04/vdsm-first-try/ ) by JXCN.
2023-04-07 23:23:01 +07:00
## Disclaimer
2023-04-23 08:07:25 +07:00
Only run this container on Synology hardware, any other use is not permitted and might not be legal according to their terms.