Commit 4b09206d authored by Kroese's avatar Kroese Committed by GitHub
Browse files

Network configuration

parent 618ecbd2
Loading
Loading
Loading
Loading
+29 −29
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ 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"
    ```
@@ -63,7 +63,7 @@ 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"
    ```
@@ -72,7 +72,7 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm

    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
    ```
@@ -83,7 +83,7 @@ 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"
    ```
@@ -94,7 +94,7 @@ 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"
@@ -104,7 +104,7 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/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:

    ```
    ```yaml
    services:
        dsm:
            container_name: qemu
            ..<snip>..
            networks:
                vlan:             
                    ipv4_address: 192.168.0.100
    ```
    
    Finally, add the network to the bottom of your compose file:

    ```
    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.