Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| omv8:omv8_plugins:docker_compose [2025/12/21 11:08] – [Add from example] chente | omv8:omv8_plugins:docker_compose [2026/01/11 09:06] (current) – [Usage in compose files] chente | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| ===== Summary ===== | ===== Summary ===== | ||
| - | [[https:// | + | [[https:// |
| Docker is a technology that enables the creation and use of Linux containers. A container is an isolated environment where one or more applications and their dependencies run using the same operating system kernel. | Docker is a technology that enables the creation and use of Linux containers. A container is an isolated environment where one or more applications and their dependencies run using the same operating system kernel. | ||
| Line 67: | Line 67: | ||
| < | < | ||
| - | {{ : | + | {{ : |
| \\ | \\ | ||
| This tab contains the general configuration options of the **openmediavault-compose** plugin. | This tab contains the general configuration options of the **openmediavault-compose** plugin. | ||
| Line 80: | Line 80: | ||
| === Compose Files === | === Compose Files === | ||
| + | {{ : | ||
| Define the folder where the plugin will store container configuration files, including Docker Compose files ('' | Define the folder where the plugin will store container configuration files, including Docker Compose files ('' | ||
| Line 709: | Line 710: | ||
| ---- | ---- | ||
| - | ==== Usage in compose files ==== | + | ==== Usage in Compose Files ==== |
| Docker configs managed in this tab can be referenced inside compose files using the standard Docker Compose syntax. | Docker configs managed in this tab can be referenced inside compose files using the standard Docker Compose syntax. | ||
| Line 715: | Line 716: | ||
| This allows configuration files to be mounted into containers at runtime without hardcoding their contents directly in the compose file. | This allows configuration files to be mounted into containers at runtime without hardcoding their contents directly in the compose file. | ||
| - | This functionality | + | **Workflow: |
| + | |||
| + | * A config file is always associated | ||
| + | * When you create or import a config in the GUI, it is stored in the same folder as the Compose file. | ||
| + | * In your Compose file, you can reference the config using its filename only, no absolute path needed. | ||
| + | * This allows you to keep all container configuration | ||
| + | |||
| + | **Example: | ||
| + | |||
| + | * You create mosquitto.conf in the Configs tab and associate it with docker-compose.yml. | ||
| + | * The plugin stores mosquitto.conf in the same folder as the compose file. | ||
| + | * In docker-compose.yml, | ||
| + | |||
| + | < | ||
| + | services: | ||
| + | mosquitto: | ||
| + | image: eclipse-mosquitto | ||
| + | volumes: | ||
| + | - .mosquitto.conf:/ | ||
| + | |||
| + | </ | ||
| + | |||
| + | **Key points:** | ||
| + | |||
| + | * Configs cannot be created outside the compose folder. | ||
| + | * This workflow saves CLI steps and keeps configuration files organized and easy to find. | ||
| + | * Recommended for users who want to manage container configs without hardcoding paths or moving files manually. | ||
| ---- | ---- | ||
| Line 979: | Line 1006: | ||
| * **Driver** | * **Driver** | ||
| * Choose the network driver type (bridge, overlay, macvlan, etc.). | * Choose the network driver type (bridge, overlay, macvlan, etc.). | ||
| + | * **bridge** – standard network bridge. | ||
| + | * **ipvlan** – network interface with minimal overhead, useful for assigning multiple IPs. | ||
| + | * **macvlan** – assign a MAC address to each container; allows containers to appear as separate devices on the LAN. | ||
| + | * **overlay** – network for multi-host container communication. | ||
| + | * **Parent Network** (only for macvlan) | ||
| + | * Select the physical network interface on the host that will act as the parent for the macvlan network. | ||
| * **Subnet** | * **Subnet** | ||
| * Define the subnet in CIDR notation (e.g., 172.20.0.0/ | * Define the subnet in CIDR notation (e.g., 172.20.0.0/ | ||
| Line 987: | Line 1020: | ||
| * **Aux Address** | * **Aux Address** | ||
| * Optional static IP assignments in the format `name=ip`. | * Optional static IP assignments in the format `name=ip`. | ||
| - | | + | * Comma separate multiple entries (e.g., `my-router=192.168.10.5, |
| * **Save** | * **Save** | ||
| * Creates the network with the defined parameters. | * Creates the network with the defined parameters. | ||
| Line 1184: | Line 1217: | ||
| {{ : | {{ : | ||
| - | {{ : | + | {{ : |
| By default, backups include all subfolders containing generated compose files. These subfolders are created automatically every time a compose file is generated via the GUI. | By default, backups include all subfolders containing generated compose files. These subfolders are created automatically every time a compose file is generated via the GUI. | ||
| Line 1207: | Line 1240: | ||
| < | < | ||
| - | </ | + | </ |
| The advantage of the plugin' | The advantage of the plugin' | ||
| </ | </ | ||
| Line 1215: | Line 1248: | ||
| === Create === | === Create === | ||
| - | {{ : | + | {{ : |
| Opens a dialog to schedule container backup and/or update jobs. | Opens a dialog to schedule container backup and/or update jobs. | ||
| Line 1444: | Line 1477: | ||
| < | < | ||
| - | </ | + | </ |
| The authentication status affects the ability to pull or push images from/to private repositories. | The authentication status affects the ability to pull or push images from/to private repositories. | ||
| </ | </ | ||
| Line 1492: | Line 1525: | ||
| This widget allows quick monitoring of active containers without entering the Compose interface. | This widget allows quick monitoring of active containers without entering the Compose interface. | ||
| - | |||
| - | ---- | ||
| - | |||
| ---- | ---- | ||
| Line 1500: | Line 1530: | ||
| ===== Usual procedures ===== | ===== Usual procedures ===== | ||
| - | ---- | + | [[omv8: |
| - | + | ||
| - | === How to implement a container using a yaml file === | + | |
| \\ | \\ | ||
| - | * If you have not already done so, define the folder where to store the configuration files. Go to **Services** > **Compose** > **Settings** In the dropdown choose a shared folder | + | You can find several common procedures for creating |
| - | * Go to **Services** > **Compose** > **Files** Click on **Create**. | + | |
| - | * Copy and paste your configuration //yaml// file into the **File** window. | + | |
| - | * Fill in the **Name** field with a name for the file. | + | |
| - | * Optionally type a description of the file in the **Description** field. | + | |
| - | * Optionally copy and paste your environment parameter file into the **Environment** window. | + | |
| - | * Press **Save**. | + | |
| - | * Press the **Up** button. The image(s) of the container(s) defined in the //yaml// file will be downloaded and those containers will be put into operation. | + | |
| - | ---- | + | See -> [[omv8:docker_in_omv# |
| - | + | ||
| - | === How to update a single docker-compose container === | + | |
| - | \\ | + | |
| - | * Go to **Services** | + | |
| - | * Press the **Pull** button. This will download the latest available image from that container. | + | |
| - | * Now go to **Services** > **Compose** > **Files** and select the file where that container is defined. | + | |
| - | * Click **Up**. The containers defined in the //yaml// file will start with the latest available image downloaded. Your container is already updated. | + | |
| - | * Press **Prune** and then press **Image**. Old images will be deleted. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | === How to update multiple containers defined in a single docker-compose yaml file === | + | |
| - | \\ | + | |
| - | * Go to **Services** > **Compose** > **Files** and select the //yaml// file that defines the containers you want to update. | + | |
| - | * Press the **Pull** button. This will download the latest images available from all containers defined in the //yaml// file. | + | |
| - | * Click **Up**. The containers defined in the //yaml// file will be started with the latest available image downloaded from each container. Your containers are already up to date. | + | |
| - | * Press **Prune** and then press **Image**. Old images will be deleted. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | === How to delete containers from a yaml file === | + | |
| - | \\ | + | |
| - | * Go to **Services** > **Compose** > **Files** and select the //yaml// file that defines the containers you want to remove. | + | |
| - | * Click **Down** to stop the containers defined in that //yaml// file. | + | |
| - | * Press **Prune** and then press **System**. All data generated by those containers will be removed from the system. | + | |
| - | * If you want to delete the //yaml// file, click **Delete**. This will remove the //yaml// file. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | === How to deploy a container using a dockerfile === | + | |
| - | \\ | + | |
| - | * If you have not already done so, define the folder where to store the configuration files. Go to **Services** > **Compose** > **Settings** In the dropdown choose a shared folder and click **Save**. | + | |
| - | * Create the // | + | |
| - | * Copy and paste your configuration // | + | |
| - | * Fill in the **Name** field with a name for the // | + | |
| - | * Optionally type a description of the // | + | |
| - | * Optionally copy and paste your //script// file into the **Script** window so that the // | + | |
| - | * Optionally copy and paste your // | + | |
| - | * Press **Save**. | + | |
| - | * Create the container and run it: | + | |
| - | * Select the // | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | === How to generate a composition yaml file with Autocompose === | + | |
| - | \\ | + | |
| - | * Go to **Services** > **Compose** > **Files** and press the **+** and then the **Autocompose** button | + | |
| - | * Expand the **Container** field. A list of all running containers will appear, select the container you want to generate a //yaml// file for. | + | |
| - | * In the **Name** field, type the name you want to use for the generated file. | + | |
| - | * In the **Description** field you can write a reminder summary of the file content. | + | |
| - | * In the **Version** field, select the version of docker-compose that will be used to generate the //yaml// file. | + | |
| - | * Press the **Create** button. The generated file will appear on a line in the Files tab list. | + | |
| - | * Select this file and press the **Edit** button to view the content of the generated file. | + | |
| - | * There will probably be more information than necessary to define the container, it would be advisable to clean up all the unnecessary lines. | + | |
| - | * If you remember roughly what the original //yaml// file looked like, you can clean up the extra information. | + | |
| - | * You can search the internet for existing information about this container. If there is an example //yaml// file you can try to adapt yours to be as similar as possible. | + | |
| - | * Press the **Save** button. | + | |
| - | * Select the file again and press the **check** button. | + | |
| - | * The output can show you possible errors. If you detect any, go back to the previous step. | + | |
| - | * Select the file and press the **Up** button. | + | |
| - | * If the container is deployed without any problems the generated yaml file works. Otherwise you should keep checking for errors until it works. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | === How to Create a VLAN (Pi-hole, Adguard, ...) === | + | |
| - | \\ | + | |
| - | This is useful if you need a container to have an IP within your LAN that is different from your server' | + | |
| - | + | ||
| - | The most common use case for this procedure is installing pi-hole in docker on an OMV server. The reason in this case is that both pi-hole and OMV need the same port to function correctly, port 53. Therefore we need pi-hole to use a different IP on our network to be able to use that port without affecting OMV. There may be other use cases besides pi-hole, depending on the needs of the container you're setting up. | + | |
| - | + | ||
| - | Note that containers using this network will expose all their ports on the LAN, just like any other IP, eg OMV. Docker provides an additional layer of security through port mapping (similar to a firewall). Through this procedure we lose that additional security layer. This does not have to be a problem, it is normal operation in any network, but it is convenient to be aware of this circumstance. Logically it will be useless to map ports in those containers, so you can save that part. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | == Creation and use of the VLAN network interface with IP in our LAN == | + | |
| - | + | ||
| - | We must create the network previously to be able to define the parameters we need and use it later in the containers. We will call it //mynet// and we will create it as follows: | + | |
| - | + | ||
| - | * In the OMV GUI go to **Services** > **Compose** > **Networks** Press the **Add** button. | + | |
| - | * Choose the name for your network and write it in the **Name** field. For example // | + | |
| - | * In the **Driver** field, drop down the menu and choose **macvlan**. | + | |
| - | * In the **Parent Network** field, drop down the menu and choose your OMV network interface. You can check it in the GUI under **Network** > **Interfaces**. | + | |
| - | * In the **Subnet** field write the IP range of your local network. Usually it can be '' | + | |
| - | * In the **Gateway** field write the gateway of your network, normally your router, something like this '' | + | |
| - | * In the **IP range** field write '' | + | |
| - | * This network range is equivalent to the IP addresses between '' | + | |
| - | * So that this is not a problem with the IP assignment of your DHCP server (your router in general) you can reduce the assignment range, instead of letting it assign from 1 to 254, we can reduce it from 1 to 235 for example. This is how we make sure we have those free IPs for docker. | + | |
| - | * In the **Aux address** field you can optionally define an IP address to reserve for the host. In this case it would be '' | + | |
| - | * This will be useful only if you need the host and the container to communicate with each other. | + | |
| - | * Press the **Save** button. At this moment the network is already created and you can use it in the configuration of any container. | + | |
| - | * You can inspect the network by selecting it and clicking the **Inspect** button to view its current values. When some container is using it, it should appear in this configuration. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | == Assigning this network interface in a container == | + | |
| - | + | ||
| - | In order for a container to use the created network interface you need to add the following lines to the end of your compose file, assuming docker-compose is version 3 or higher. See the documentation for older versions of docker-compose. | + | |
| - | + | ||
| - | + | ||
| - | < | + | |
| - | pi-hole: | + | |
| - | container_name: | + | |
| - | . | + | |
| - | . | + | |
| - | <FONT COLOR=" | + | |
| - | mynet: | + | |
| - | ipv4_address: | + | |
| - | networks: | + | |
| - | mynet: | + | |
| - | external: true</ | + | |
| - | + | ||
| - | This sets up the mynet interface for that container and assigns it the IP value '' | + | |
| - | + | ||
| - | When we start the container we will be able to access its interface from the assigned IP and the usual port. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | == Reduce the IP range of the DHCP server (usually the router) == | + | |
| - | + | ||
| - | Once the above is done, in order to avoid overlapping assignable IP ranges, it would be advisable to reduce the IP range of the network' | + | |
| - | In the case of the previous configuration it could be set to: | + | |
| - | + | ||
| - | * From 192.168.1.2 | + | |
| - | * Up to 192.168.1.239 | + | |
| - | + | ||
| - | This way addresses from 192.168.1.240 onwards will always be available, since the router will not assign any of these IPs if a device requests an IP assignment. | + | |
| - | + | ||
| - | If you use the container itself as a DHCP server, for example with pi-hole, you must disable the DHCP server on your router and adapt the DHCP range in pi-hole accordingly. | + | |
| - | + | ||
| - | ---- | + | |
| - | + | ||
| - | == If we need communication between the containers and the host == | + | |
| - | + | ||
| - | What has been applied so far is enough to use pihole, but in the case of other different containers it may be necessary for the container and the host to communicate with each other. Vlans have a limitation, by design they cannot communicate with the host. To overcome this setback and allow communication between the containers and the host, if necessary, we can create a network interface that will act as a bridge between the two. | + | |
| - | + | ||
| - | < | + | |
| - | Warning | + | |
| - | </ | + | |
| - | What follows from now on is a procedure that creates a binding interface for communication with the host via / | + | |
| - | If you have a suggestion to do this in a safe way you can post it in the forum. | + | |
| - | </ | + | |
| - | + | ||
| - | Running the following commands would create this interface, but this configuration would not be persistent in OMV. On the first server restart it would disappear: | + | |
| - | + | ||
| - | < | + | |
| - | ip addr add 192.168.1.239/ | + | |
| - | ip link set mynet-host up | + | |
| - | ip route add 192.168.1.224/ | + | |
| - | + | ||
| - | This would create a macvlan network interface called mynet-host in bridge mode that would use the IP '' | + | |
| - | + | ||
| - | To make this configuration persistent in OMV we must do it as follows: | + | |
| - | + | ||
| - | * Create a network interface configuration file: | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | * Copy into that file the following content: | + | |
| - | + | ||
| - | < | + | |
| - | iface mynet-host inet static | + | |
| - | pre-up ip link add mynet-host link eno1 type macvlan mode bridge | + | |
| - | address 192.168.1.239/ | + | |
| - | up ip link set mynet-host up | + | |
| - | up ip route add 192.168.1.224/ | + | |
| - | + | ||
| - | * Replace '' | + | |
| - | * Save changes and exit the editor. '' | + | |
| - | * Restart the service or the server. | + | |
| - | + | ||
| - | From now on those settings will be set every time the server is started. | + | |
| - | + | ||
| - | < | + | |
| - | </ | + | |
| - | If for some reason you need to create many different IPs keep in mind that macvlan uses different MAC addresses for each IP. This can be a problem if your hardware has a limit on the maximum number of MACs for the same physical interface. In that case you can change the configuration to ipvlan. Consult the official docker documentation in this regard to solve other possible configuration problems with ipvlan. | + | |
| - | </ | + | |
| ---- | ---- | ||