Network configuration
This commit is contained in:
parent
618ecbd203
commit
4b09206d5b
1 changed files with 29 additions and 29 deletions
58
readme.md
58
readme.md
|
@ -52,9 +52,9 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm
|
|||
|
||||
You can modify the `BOOT` environment variable to specify the URL of an ISO image:
|
||||
|
||||
```
|
||||
```yaml
|
||||
environment:
|
||||
BOOT: "http://www.example.com/image.iso"
|
||||
BOOT: "http://www.example.com/image.iso"
|
||||
```
|
||||
|
||||
It will be downloaded only once, during the initial run of the container.
|
||||
|
@ -63,18 +63,18 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm
|
|||
|
||||
To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity:
|
||||
|
||||
```
|
||||
```yaml
|
||||
environment:
|
||||
DISK_SIZE: "256G"
|
||||
DISK_SIZE: "256G"
|
||||
```
|
||||
|
||||
* ### How do I change the location of the data disk?
|
||||
|
||||
To change the data disk's location from the default docker volume, include the following bind mount in your compose file:
|
||||
|
||||
```
|
||||
```yaml
|
||||
volumes:
|
||||
- /home/user/data:/storage
|
||||
- /home/user/data:/storage
|
||||
```
|
||||
|
||||
Replace the example path `/home/user/data` with the desired storage folder.
|
||||
|
@ -83,9 +83,9 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm
|
|||
|
||||
By default, the entire disk space is reserved in advance. To create a growable disk, that only reserves the space that is actually used, add the following environment variable:
|
||||
|
||||
```
|
||||
```yaml
|
||||
environment:
|
||||
ALLOCATE: "N"
|
||||
ALLOCATE: "N"
|
||||
```
|
||||
|
||||
Keep in mind that this will not affect any of your existing disks, it only applies to newly created disks.
|
||||
|
@ -94,17 +94,17 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm
|
|||
|
||||
By default, a single core and 512MB of RAM is allocated to the container. To increase this, add the following environment variables:
|
||||
|
||||
```
|
||||
```yaml
|
||||
environment:
|
||||
CPU_CORES: "4"
|
||||
RAM_SIZE: "2048M"
|
||||
CPU_CORES: "4"
|
||||
RAM_SIZE: "2048M"
|
||||
```
|
||||
|
||||
* ### How do I verify if my system supports KVM?
|
||||
|
||||
To verify if your system supports KVM, run the following commands:
|
||||
|
||||
```
|
||||
```bash
|
||||
sudo apt install cpu-checker
|
||||
sudo kvm-ok
|
||||
```
|
||||
|
@ -117,27 +117,27 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm
|
|||
|
||||
If you want to assign an individual IP address to the container, you can create a macvlan network as follows:
|
||||
|
||||
```
|
||||
$ docker network create -d macvlan \
|
||||
```bash
|
||||
docker network create -d macvlan \
|
||||
--subnet=192.168.0.0/24 \
|
||||
--gateway=192.168.0.1 \
|
||||
--ip-range=192.168.0.100/28 \
|
||||
-o parent=eth0 vlan
|
||||
```
|
||||
|
||||
Be sure to modify the values to match your local subnet.
|
||||
Be sure to modify these values to match your local subnet.
|
||||
|
||||
Once you have created the network, modify the container's configuration in your compose file as follows:
|
||||
Once you have created the network, change your compose file to make it look as follows:
|
||||
|
||||
```
|
||||
networks:
|
||||
vlan:
|
||||
ipv4_address: 192.168.0.100
|
||||
```
|
||||
|
||||
Finally, add the network to the bottom of your compose file:
|
||||
```yaml
|
||||
services:
|
||||
dsm:
|
||||
container_name: qemu
|
||||
..<snip>..
|
||||
networks:
|
||||
vlan:
|
||||
ipv4_address: 192.168.0.100
|
||||
|
||||
```
|
||||
networks:
|
||||
vlan:
|
||||
external: true
|
||||
|
@ -145,21 +145,21 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm
|
|||
|
||||
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.
|
||||
|
||||
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 workarounds available, but they go beyond the scope of this FAQ.
|
||||
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.
|
||||
|
||||
* ### How can the container acquire an IP address from my router?
|
||||
|
||||
After configuring the container for macvlan (see above), it will now be able to join your home network by requesting an IP from your router, just like your other devices.
|
||||
After configuring the container for macvlan (see above), it is possible for the VM to become part of your home network by requesting an IP from your router, just like your other devices.
|
||||
|
||||
To enable this, add the following lines to your compose file:
|
||||
To enable this feature, add the following lines to your compose file:
|
||||
|
||||
```
|
||||
```yaml
|
||||
environment:
|
||||
DHCP: "Y"
|
||||
devices:
|
||||
- /dev/vhost-net
|
||||
device_cgroup_rules:
|
||||
- 'c 510:* rwm'
|
||||
- 'c 511:* rwm'
|
||||
```
|
||||
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue