Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

请教一下,compose如何设置容器为静态IP?

Featured Replies

version: '3.3'
services:
    test:
        container_name: test
        restart: always
        ports:
            - '80:80'
        image: 'test/test:latest'
        networks:
            br0:
                ipv4_address: 192.168.50.231
networks:
  br0:
    external: true
    ipam:
      config:
        - subnet: 192.168.50.0/24

这样设置可以设置为静态IP,但是“网络”那一栏则变成了随机字符~

image.png.305a04d6c7a62a87bcb4fe37962e4136.png

 

请教一下各位,有更好的实现办法吗?先感谢各位

Solved by Liviter

  • Author
  • Solution

已经自行解决~大家可以关注英文板块的相关帖子,找得到答案~

给后面看到这个帖子的朋友:

 

version: '3.8'

services:
    qbittorrent:
        image: lscr.io/linuxserver/qbittorrent:latest
        container_name: qbittorrent
        networks:
          br0:
            ipv4_address: 192.168.1.99

networks:
    br0:
      external: true

 

  • 如果需要让容器使用固定的 IP 地址,需要使用 ipv4_address 进行配置;
  • br0 即 Unraid 上的桥接网络虚拟网卡设备,如果你有多个物理网卡都开启了桥接网络,那么你可以将其更改为 br1 、br2 或者 eth1 等虚拟网卡设备;
  • 需要说明的是,使用这种方法安装的 docker ,在 Unraid 的 Docker 管理界面上,“网络”会显示为一串字符,该字符为 Docker 网络的网络 ID,如 #4 的朋友所示,此现象是由于 docker-compose 插件近段时间更新之后导致的(以前是正常显示网络名称的)。如果你用的是 6.12 版本,那么你可以参考下面 #6 楼朋友的解决办法进行解决;

Edited by JackieWu

On 1/11/2024 at 4:42 PM, JackieWu said:

给后面看到这个帖子的朋友:

 

version: '3.8'

services:
    qbittorrent:
        image: lscr.io/linuxserver/qbittorrent:latest
        container_name: qbittorrent
        networks:
            testnetwork:
            ipv4_address: 192.168.1.100

networks:
    testnetwork:
        external: true
        name: br0
  • testnetwork 是 docker-compose 里面一个自定义的网络,用于指向外部的网络。
  • 当你需要给容器设定一个与 unraid 同网段的固定 IP 地址时,你需要将这个 testnetwork 指向 unraid 上的 br0 (或者其他的网络接口)。
  • 将 testnetwork 指向外部网络接口的语法,在尾部的 network 元素中定义。

我按照这里的模板配置了docker,但是网络还是会显示和楼主类似的一串id,搜了下Reddit和unraid论坛英文版也没找到解决办法,想正常显示br0只能放弃compose吗

mmexport1705545524888.jpg

mmexport1705545523410.jpg

mmexport1705545521831.jpg

On 1/18/2024 at 10:39 AM, attentive-feat1829 said:

我按照这里的模板配置了docker,但是网络还是会显示和楼主类似的一串id,搜了下Reddit和unraid论坛英文版也没找到解决办法,想正常显示br0只能放弃compose吗

 

 

我对原文的回复进行了修改,你可以参考看看。

  • Author
On 1/18/2024 at 10:39 AM, attentive-feat1829 said:

我按照这里的模板配置了docker,但是网络还是会显示和楼主类似的一串id,搜了下Reddit和unraid论坛英文版也没找到解决办法,想正常显示br0只能放弃compose吗

mmexport1705545524888.jpg

mmexport1705545523410.jpg

mmexport1705545521831.jpg

 

这两个文件,丢入/usr/local/emhttp/plugins/dynamix.docker.manager/include目录下

更换文件风险自断

 

文件来源于论坛的
 

  

On 1/3/2024 at 11:42 AM, mtongnz said:

I've been playing with the code behind this plugin and have made a couple of tweaks.  I'd be interested on peoples thoughts and suggestions.

 

The first allows you to specify any .env file.  This allows use of a central env for all your compose files.

https://github.com/dcflachs/compose_plugin/pull/24

 

Update the built in unRaid image versions so the GUI correctly shows updates for containers.  I'm still testing this before doing a PR.

https://github.com/dcflachs/compose_plugin/commit/4297b46fdfeaa077f405a328ee074606363d5f9b

 

I've tweaked how the network info is shown in the GUI.  It now shows all network names with the associated IP.  This is in the dynamix.docker.manager plugin which is a core part of unRaid's GUI - so not technically part of this plugin.

You need to set the label net.unraid.docker.managed: 'composeman' for this to work (this is usually done with the overide yaml).

https://github.com/unraid/webgui/issues/1569

Here's a screenshot of it:  I've contemplated making the network name bold but I don't think it's needed.

image.png.23e74e459187fe1733a941148e85e6a9.png

 

 

At present, these all need to be implemented by overwriting the files in /usr/local/emhttp/plugins/.  Look at the commits to see what files need to be edited.

 

  

 

DockerClient.php DockerContainers.php

Edited by Liviter

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.