omv6:omv6_plugins:docker_compose [omv-extras.org]
Docker是一种支持创建和使用Linux容器的技术。容器是在同一操作系统内核上运行的一个封闭环境,其中一个或多个应用程序及其依赖项被安装、分组和隔离。
Docker允许您根据需要多次安装,卸载,修改,更新应用程序,而不会对系统造成损坏。
openmediavault-compose 插件在 openmediavault GUI 中提供了一个工具,用于使用 docker compose 创建和管理容器。
提供了两种管理方法:
通过 YAML 文件。
通过 dockerfiles。
所有生成的文件(yaml,env,dockerfiles等)都存储在用户定义的文件夹中。
In OMV6's GUI:
Under System > Plugins find and highlight openmediavault-compose 6.X, and click the Install button.
在安装 docker 之前,有必要激活 docker 存储库。转到系统> omv-extras 单击Docker存储库按钮,然后单击“保存”按钮。
This is the plugin settings window.
In this window we can select the configuration file storage folder, we can define the docker installation place and we can install uninstall or restart docker.
这是插件设置窗口。
在此窗口中,我们可以选择配置文件存储文件夹,我们可以定义 docker 安装位置,我们可以安装卸载或重新启动 docker。
Under Services > Compose > Settings
在“服务”>“撰写>设置”下
Note | |
It is a good idea to make backups of this folder. In case of reinstallation of OMV it is the only thing you need to redeploy your containers. 最好备份此文件夹。在重新安装 OMV 的情况下,您唯一需要重新部署容器的事情。 |
/var/lib/docker
/var/lib/docker
Notes | |
This folder will store docker's internal working files, images, containers, etc. You do not need to back up this folder, it does not store any information that should be persistent. 此文件夹将存储 docker 的内部工作文件、映像、容器等。您不需要备份此文件夹,它不存储任何应该持久化的信息。 |
Files is the yaml and env file management window, for configuring containers with docker-compose.
In this window you can perform any action necessary to manage these files, including creating, modifying, deleting, starting or stopping containers, updating images, etc.
The files generated here will be stored in subfolders within the folder configured in the plugin in the previous point.
The window displays a list of existing files and a top bar with buttons to perform various actions.
Selecting a file activates the buttons on the top bar.
Allows you to act on the container or containers defined in a yaml file simultaneously. Actions executed in this tab will be applied to all containers defined in the yaml file.
Files 是 yaml 和 env 文件管理窗口,用于使用 docker-compose 配置容器。
在此窗口中,您可以执行管理这些文件所需的任何操作,包括创建、修改、删除、启动或停止容器、更新映像等。
这里生成的文件将存储在上一点插件中配置的文件夹内的子文件夹中。
该窗口显示现有文件的列表和一个顶部栏,其中包含用于执行各种操作的按钮。
选择一个文件将激活顶部栏上的按钮。
允许您同时对 yaml 文件中定义的一个或多个容器执行操作。在此选项卡中执行的操作将应用于 yaml 文件中定义的所有容器。
Under Services > Compose > Files
在“服务”下>撰写>文件
Allows you to create the yaml and env configuration files of a container. Pressing the button will open a dialog window with the following fields:
支持创建容器的 yaml 和 env 配置文件。按下按钮将打开一个对话框窗口,其中包含以下字段:
https://hub.docker.com/r/linuxserver/resilio-sync
Allows you to create example wrappers from preconfigured yaml files in the plugin.
允许您从插件中预配置的 yaml 文件创建示例包装器。
Allows you to create yaml configuration files from containers running on the system that have not been created with compose. Use only when necessary, the generated file will be much larger than necessary to deploy a container. Useful if you have lost the configuration data of a container created in the CLI.
允许您从系统上运行的容器创建 yaml 配置文件,这些容器尚未使用 compose 创建。仅在必要时使用,生成的文件将比部署容器所需的大得多。如果您丢失了在 CLI 中创建的容器的配置数据,则很有用。
Note | |
In the Add from example button there is a file prepared to generate a Composerize container, which will generate yaml files from docker CLI container generation commands. 在“从示例添加”按钮中,有一个文件准备用于生成 Composerize 容器,该文件将从 docker CLI 容器生成命令生成 yaml 文件。 |
Allows you to import existing compose compose files into the plugin.
允许您将现有的撰写文件导入插件。
在对话框中,输入包含 yaml 文件的文件夹的路径。
如果您的 yaml 文件位于具有相同名称的 yaml 文件和子文件夹的子文件夹中,则导入将成功:
compose_files
作曲1
组合1.yml
compose1.env
作曲2
组合2.yml
compose2.env
...
单击创建按钮。
Allows you to edit the yaml and env files of the selected file.
The window is the same as the Create button already seen.
Activates when selecting a file.
允许您编辑所选文件的 yaml 和 env 文件。
该窗口与已看到的“创建”按钮相同。
选择文件时激活。
Allows you to delete a file.
The corresponding subfolder in compose folder along with the yaml and env configuration files will also be removed.
Activates when selecting a file.
允许您删除文件。
撰写文件夹中的相应子文件夹以及yaml和env配置文件也将被删除。
选择文件时激活。
It will check the configuration of a file and report possible errors if they are detected.
Util before launching the defined container or containers.
Any error that appears in a red box can be copied to the clipboard from the notifications button in the top bar of OMV to read it in its entirety.
Activates when selecting a file.
它将检查文件的配置,并在检测到可能的错误时报告错误。
在启动定义的一个或多个容器之前使用。
出现在红色框中的任何错误都可以从OMV顶部栏中的通知按钮复制到剪贴板,以完整阅读。
选择文件时激活。
Allows you to start the containers belonging to the selected yaml file.
If this is the first start, the container images will be downloaded, then the containers defined in the file will be put into operation.
Activates when selecting a file.
允许您启动属于所选 yaml 文件的容器。
如果这是第一次启动,则将下载容器映像,然后将文件中定义的容器投入运行。
选择文件时激活。
Allows you to stop the containers defined in the selected file. Useful if some monitoring needs to find the container and see the output message.
Activates when selecting a file.
允许您停止所选文件中定义的容器。如果某些监视需要查找容器并查看输出消息,则非常有用。
选择文件时激活。
Allows you to stop and remove the containers defined in the selected file.
Activates when selecting a file.
允许您停止和删除所选文件中定义的容器。
选择文件时激活。
Allows you to download the latest images available on the internet from the containers defined in the selected file.
Previous images are still on the system. To remove old images you can use the prune button.
Activates when selecting a file.
允许您从所选文件中定义的容器下载互联网上可用的最新映像。
以前的映像仍在系统上。要删除旧图像,您可以使用修剪按钮。
选择文件时激活。
Allows you to see in a pop-up window the status of the containers defined in the selected file.
Activated when selecting a file.
允许您在弹出窗口中查看所选文件中定义的容器的状态。
选择文件时激活。
Allows you to clean the system of images, containers, volumes or networks that are no longer needed and recover space.
允许您清理系统中不再需要的映像、容器、卷或网络并恢复空间。
Link to this guide.
This is the container creation dockefiles management window.
As in the files window, dockerfiles are managed in this window to perform any action on them. here the dockerfiles are created, modified, deleted, the created containers can be started, etc.
The generated dockerfiles will be stored in the folder configured in settings, using subfolders generated by the plugin.
The window shows a list of generated dockerfiles and a top bar of buttons that allow executing the actions required in each case.
Selecting a dockerfile activates the action buttons.
这是容器创建 dockefile 管理窗口。
与在文件窗口中一样,docker文件在此窗口中进行管理,以对其执行任何操作。在这里,Docker文件被创建,修改,删除,创建的容器可以启动,等等。
生成的 dockerfile 将使用插件生成的子文件夹存储在设置中配置的文件夹中。
该窗口显示生成的 dockerfile 列表和按钮顶部栏,这些按钮允许执行每种情况下所需的操作。
选择 dockerfile 将激活操作按钮。
Under Services > Compose > Dockerfiles
Popup window to create a container using a dockerfile.
弹出窗口,用于使用 dockerfile 创建容器。
名字
在系统中指定此 dockerfile 的名称。
描述
dockerfile 函数的描述,以帮助识别它。
Dockerfile
在这里,您可以创建(或复制并粘贴)用于创建容器的 dockerfile。
脚本文件名
包含脚本的文件的名称。
脚本
(可选)在这里,您可以创建(或复制并粘贴)一个带有脚本的文件,该脚本将在运行时调用 dockerfile。
会议文件名
具有环境参数的文件的名称。
会议文件
(可选)您可以在此处创建(或复制并粘贴)要包含在映像中的配置文件。
Allows you to edit the dockerfile, script, and conf files of the selected container.
The window is the same as the Create button already seen.
Triggered by selecting a dockerfile.
允许您编辑所选容器的 dockerfile、脚本和 conf 文件。
该窗口与已看到的“创建”按钮相同。
通过选择 docker 文件触发。
Allows you to delete a container.
The corresponding subfolder in compose folder along with the dockerfile, script and conf configuration files will also be removed.
Triggered by selecting a dockerfile.
允许您删除容器。
compose 文件夹中的相应子文件夹以及 dockerfile、script 和 conf 配置文件也将被删除。
通过选择 docker 文件触发。
It allows deploying the container following the dockerfile already configured.
Triggered by selecting a dockerfile.
它允许按照已配置的 dockerfile 部署容器。
通过选择 docker 文件触发。
Shows a list of running containers displaying the basic execution data.
Selecting a container activates the buttons on the top bar.
It allows acting on the containers individually. Actions executed in this tab will be applied only to the selected container, regardless of whether the yaml file defines one or more containers.
The Ports column will display a link that provides access to the GUI of each container via its port and the domain the server uses, opening a new tab in the web browser. Your router has to allow DNS registration of the other domain names and the client with the browser has to be able to look up that fqdn in dns. How that is done depends on the router/DHCP/DNS system you are using.
显示基本执行数据的正在运行的容器的列表。
选择容器将激活顶部栏上的按钮。
它允许单独作用于容器。在此选项卡中执行的操作将仅应用于所选容器,无论 yaml 文件是否定义了一个或多个容器。
“端口”列将显示一个链接,该链接通过每个容器的端口和服务器使用的域提供对每个容器的GUI的访问,并在Web浏览器中打开一个新选项卡。您的路由器必须允许其他域名的 DNS 注册,并且浏览器客户端必须能够在 DNS 中查找该 fqdn。如何完成取决于您使用的路由器/ DHCP / DNS系统。
Under Services > Compose > Containers
Allows you to download the latest image of the selected container available on the internet.
The behavior is the same as in Files pull but only the image of the selected container is downloaded, not all the containers that have been generated by the yaml file.
Activated by selecting a container.
Allows you to display the selected container.
The behavior is the same as Files up but only the selected container will be started, not all the containers that have been generated by the yaml file.
Activates when selecting a container.
Allows you to restart the selected container.
Activated when selecting a container.
Allows you to view the log of the selected container.
Activated when selecting a container.
Shows a list of running containers displaying the usage status of the resources used.
Selecting a container activates the buttons on the top bar.
Docker inspect provides detailed information about builds controlled by Docker.
Activated when selecting a container.
Allows you to view the log of the selected container.
Activated when selecting a container.
There are three widgets on the dashboard that provide docker container information:
If you upgraded the plugin version to openmediavalt-compose 6.7 and had Portainer installed from omv-extras, at this point all your containers continue to work as usual and are reachable on their usual IP address and port, but you cannot access their functionality from the OMV GUI.
Portainer is just one more container, like the rest, therefore, the situation is the same.
To continue using Portainer, the procedure is to reinstall this container from the openmediavault-compose plugin, for this, you must first stop the Portainer container and remove it (This will not delete the existing configurations in the Portainer, only the container which can then be recreated keeping its current configuration). The way to do this requires running two simple commands on the CLI. Once this is done, the plugin allows you to retrieve the container to the existing path and working exactly as it did before.
If you did not have the plugin installed before the update, you must first install it and configure the Shared folder to store the yaml files.
The procedure to recover Portainer is as follows:
sudo docker stop portainer
sudo docker rm portainer
如果您将插件版本升级到 openmediavalt-compose 6.7 并从 omv-extras 安装了 Portainer,此时您的所有容器都可以继续照常工作,并且可以通过其通常的 IP 地址和端口访问,但您无法从 OMV GUI 访问它们的功能。
Portainer只是另一个容器,就像其他容器一样,因此,情况是一样的。
要继续使用 Portainer,该过程是从 openmediavault-compose 插件重新安装此容器,为此,您必须首先停止 Portainer 容器并将其删除(这不会删除 Portainer 中的现有配置,只会删除容器,然后可以重新创建容器,保持其当前配置)。执行此操作的方法需要在 CLI 上运行两个简单的命令。完成此操作后,该插件允许您将容器检索到现有路径并完全像以前一样工作。
如果在更新之前未安装插件,则必须首先安装它并配置共享文件夹以存储 yaml 文件。
恢复波泰纳的过程如下:
sudo docker stop portainer
sudo docker rm portainer
Note | |
There are two example Portainer yaml files: 有两个示例Portainer yaml文件: |
Note | |
This file extracts the Portainer Community Edition image, which is used by most people. 此文件提取了大多数人使用的Portainer社区版图像。 |
在“名称”字段中,写下 portainer
在“描述”字段中,您可以编写 portainer(可选字段)
按保存按钮
选择portainer文件的行(黄色)
按向上按钮
如果它给出错误,您可能需要重新安装 docker。在“服务>撰写>设置”中,单击“重新安装 Docker”按钮,然后再次单击“向上”按钮。
现在,您的Portainer容器的工作方式与您拥有的完全相同,您可以像以前一样从Portainer管理容器。
To recover any previously installed containers from the Portainer GUI and redeploy it to the plugin GUI the procedure is the same as for retrieving the Portainer container described above. With the exception that it will be necessary to have the configuration yaml file (stack).
要从 Portainer GUI 恢复任何以前安装的容器并将其重新部署到插件 GUI,该过程与检索上述 Portainer 容器的过程相同。除了需要配置 yaml 文件(堆栈)之外。
Note | |
This is not an ideal situation, the generated file contains information that is not necessary and can prevent the container from running in some cases. You must locate the errors and correct them. 这不是理想的情况,生成的文件包含不必要的信息,并且在某些情况下可能会阻止容器运行。您必须找到错误并更正它们。 |
生成此文件后,请按照所述过程恢复 Portainer 容器,但不要查找示例 yaml 文件,而是使用生成的 yaml 文件。
To remove Portainer
删除搬运工
Notes | |
- Portainer is just a tool to manage other containers, it's just another container. The operation of Portainer is independent of the operation of other containers. - Portainer只是一个管理其他容器的工具,它只是另一个容器。Portainer的操作独立于其他集装箱的操作。 |
This is useful if you need a container to have an IP within your LAN that is different from your server's.
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.
如果您需要容器在 LAN 中具有与服务器不同的 IP,这将非常有用。
此过程最常见的用例是在 OMV 服务器上的 docker 中安装 pi-hole。在这种情况下,原因是 pi-hole 和 OMV 都需要相同的端口才能正常工作,即端口 53。因此,我们需要 pi-hole 在我们的网络上使用不同的 IP,以便能够在不影响 OMV 的情况下使用该端口。除了 pi-hole 之外,可能还有其他用例,具体取决于您正在设置的容器的需求。
请注意,使用此网络的容器将在 LAN 上公开其所有端口,就像任何其他 IP(例如 OMV)一样。Docker 通过端口映射(类似于防火墙)提供额外的安全层。通过此过程,我们失去了额外的安全层。这不一定是问题,在任何网络中都是正常运行,但是了解这种情况很方便。从逻辑上讲,映射这些容器中的端口是没有用的,因此您可以保存该部分。
Interim procedure until the next plugin update is released.
We must create the network manually to be able to define the parameters we need and use it later in the containers. We'll call it mynet and create it using the following command (copy and paste into an SSH terminal):
发布下一个插件更新之前的临时程序。
我们必须手动创建网络,以便能够定义我们需要的参数,并在以后的容器中使用它。我们将它称为mynet,并使用以下命令创建它(复制并粘贴到SSH终端中):
docker network create -d macvlan -o parent=eno1 \
--subnet 192.168.1.0/24 \
--gateway 192.168.1.1 \
--ip-range 192.168.1.240/29 \
--aux-address 'host=192.168.1.247' \
mynet
192.168.1.0
192.168.1.1
eno1
mynet
192.168.1.0
192.168.1.1
eno1
mynet
This newly created interface, , will assign addresses in the established range , that is, from IP to IP . Therefore we can use this interface up to a maximum of 6 containers (you can expand it if you need more). So that this is not a problem with the IP assignment of your DHCP server (your router generally) you can reduce the assignment range, instead of allowing it to assign from 1 to 254, we can reduce it to from 1 to 235 for example. This is how we make sure to have those IPs free for docker. mynet
192.168.1.240/29
192.168.1.241
192.168.1.246
Procedure to apply when the next plugin update is released.
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:
192.168.1.0/24
192.168.1.1
192.168.1.240/29
192.168.1.241
192.168.1.246
host=192.168.1.247
这个新创建的接口 将分配已建立范围内的地址,即从 IP 到 IP 。因此,我们最多可以使用此接口 6 个容器(如果需要更多容器,可以扩展它)。为了使DHCP服务器(通常是路由器)的IP分配不是问题,您可以缩小分配范围,而不是允许它从1分配到254,例如,我们可以将其从1减少到235。这就是我们如何确保这些 IP 免费用于 docker。mynet
192.168.1.240/29
192.168.1.241
192.168.1.246
发布下一个插件更新时要应用的过程。
我们必须先创建网络,以便能够定义我们需要的参数,并在以后的容器中使用它。我们称之为mynet,我们将按如下方式创建它:
192.168.1.0/24
192.168.1.1
192.168.1.240/29
192.168.1.241
192.168.1.246
host=192.168.1.247
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.
为了使容器使用创建的网络接口,您需要将以下行添加到撰写文件的末尾,假设 docker-compose 是版本 3 或更高版本。请参阅旧版本的 docker-compose 的文档。
services:
pi-hole:
container_name: "pi-hole"
.
.
networks: mynet: ipv4_address: 192.168.1.241 networks: mynet: external: true
This sets up the mynet interface for that container and assigns it the IP value within our network, which was the first available. We will still be able to use up to in other containers. 192.168.1.241
246
When we start the container we will be able to access its interface from the assigned IP and the usual port. If you don't need communication between the host and the containers, you're done.
这将为该容器设置 mynet 接口,并为其分配我们网络中的 IP 值,这是第一个可用的。我们仍然可以在其他容器中使用。192.168.1.241
246
当我们启动容器时,我们将能够从分配的 IP 和常用端口访问其接口。如果不需要主机和容器之间的通信,则已完成。
What has been applied so far is enough to use pihole and other applications, but sometimes 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.
到目前为止已经应用的内容足以使用 pihole 和其他应用程序,但有时可能需要容器和主机相互通信。VLAN 有一个限制,根据设计,它们无法与主机通信。为了克服这一挫折并允许容器和主机之间的通信,如有必要,我们可以创建一个网络接口,作为两者之间的桥梁。
Warning | |
This procedure creates a binding interface for communication with the host via /etc/network/interfaces when OMV is using netplan. This can generate some conflict in certain circumstances. Do it at your own risk. 此过程创建一个绑定接口,用于在 OMV 使用 netplan 时通过 /etc/network/interfaces 与主机进行通信。在某些情况下,这可能会产生一些冲突。风险自负。 |
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:
运行以下命令将创建此接口,但此配置不会在 OMV 中持久化。在第一次服务器重新启动时,它将消失:
ip link add mynet-host link eno1 type macvlan mode bridge
ip addr add 192.168.1.239/32 dev mynet-host
ip link set mynet-host up
ip route add 192.168.1.224/28 dev mynet-host
This would create a macvlan network interface called mynet-host in bridge mode that would use the IP . The host would use this network interface thanks to the static route set in the network range to communicate with the containers. 192.168.1.239
192.168.1.224/28
To make this configuration persistent in OMV we must do it as follows:
这将在桥接模式下创建一个名为mynet-host的macvlan网络接口,该接口将使用IP。由于在网络范围内设置了静态路由,主机将使用此网络接口与容器通信。192.168.1.239
192.168.1.224/28
要使此配置在OMV中持久存在,我们必须执行以下操作:
nano /etc/network/interfaces.d/99-mynet-host
将以下内容复制到该文件中:
auto mynet-host
iface mynet-host inet static
pre-up ip link add mynet-host link eno1 type macvlan mode bridge
address 192.168.1.239/32
up ip link set mynet-host up
up ip route add 192.168.1.224/28 dev mynet-host
eno1
Ctrl+X
Yes
From now on those settings will be set every time the server is started.
eno1
Ctrl+X
Yes
从现在开始,每次启动服务器时都会设置这些设置。
Note | |
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. 如果由于某种原因您需要创建许多不同的IP,请记住macvlan为每个IP使用不同的MAC地址。如果您的硬件对同一物理接口的最大 MAC 数量有限制,则这可能是一个问题。在这种情况下,您可以将配置更改为 ipvlan。在这方面,请查阅官方 docker 文档,以解决 ipvlan 的其他可能的配置问题。 |
→ openmediavault-compose