0

网箱 534a7d1fe0bf (v3.1.6)
插件 0.9.2

我是 docker-compose 和 netbox 的新手。现在我正在尝试使用一个名为nextbox-ui-plugin 的插件来显示我们的交换机和路由器的拓扑。我在 docker 环境中安装了 netbox,并安装了 docker 安装文档中的插件。我有一些设备已连接,但拓扑查看器为空。我试图找出问题。

我的 linux 服务器中显示的错误大约为 403

netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *7 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/js/next.js") failed (13: Permission denied) 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *6 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/css/next.css") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/js/next.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/css/next.css HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/button_utils.js HTTP/1.1" 200 1504 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *6 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_app.js HTTP/1.1" 200 14227 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *7 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/js/next.js") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/js/next.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/next_sources/css/next.css") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/next_sources/css/next.css HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.4.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43" 
netbox-docker-netbox-1 | 2022/02/07 08:14:26 [error] 18#20 *5 open("/opt/netbox/netbox/static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js") failed (13: Permission denied) 
netbox-docker-netbox-1 | 192.168.146.1 - - [07/Feb/2022:08:14:26 +0000] "GET /static/nextbox_ui_plugin/jquery/jquery-3.5.1.min.js HTTP/1.1" 403 54 "http://192.168.146.143:8000/plugins/nextbox-ui/topology/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36 Edg/98.0.1108.43"

好像我的许可失败了。类似的已解决问题对我没有帮助。(#68#86)。它们都在 Dockerfile 中显示了问题。

Dockerfile

ARG FROM_IMAGE=netboxcommunity/netbox
ARG FROM_TAG=latest-ldap
ARG FROM=${FROM_IMAGE}:${FROM_TAG}
FROM ${FROM}

ENV VIRTUAL_ENV=/opt/netbox/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY ./nextbox_ui_plugin /source/nextbox-ui-plugin/nextbox_ui_plugin/
COPY ./setup.py /source/nextbox-ui-plugin/
COPY ./MANIFEST.in /source/nextbox-ui-plugin/
COPY ./README.md /source/nextbox-ui-plugin/
COPY (blank) ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin
RUN pip3 install --no-cache-dir nextbox-ui-plugin  

有人告诉我,这COPY --chown=1000:1000 (--chmod 755) ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin可以结束我的噩梦。但是无论我在空白处写什么,我都无法将/opt/netbox/netbox/static/nextbox_ui_plugin中的文档权限更改为 644 或 755 或 777。

关于权限

[root@localhost ~]# docker exec -it 534a7d1fe0bf /bin/bash
bash-5.1$ ls -al
total 12
drwxr-xr-x 1 root root 20 Jan 18 05:54 .
drwxr-xr-x 1 root root 18 Jan 18 05:54 ..
drwxr-xr-x 1 root root 39 Jan 18 05:55 circuits
drwxr-xr-x 1 root root 39 Jan 18 05:55 dcim
drwxr-xr-x 1 root root 63 Jan 18 05:55 extras
-rwxr-xr-x 1 root root 277 Jan 18 05:51 generate_secret_key.py
drwxr-xr-x 1 root root 39 Jan 18 05:55 ipam
-rwxr-xr-x 1 root root 249 Jan 18 05:51 manage.py
drwxrwxr-x 4 unit root 56 Jan 24 02:03 media
drwxr-xr-x 1 root root 28 Jan 18 05:55 netbox
drwxr-xr-x 1 root root 18 Jan 18 05:51 project-static
drwxr-xr-x 2 root root 25 Jan 18 05:51 reports
drwxr-xr-x 2 root root 25 Jan 18 05:51 scripts
drwxr-xr-x 1 root root 31 Jan 24 01:23 static
drwxr-xr-x 17 root root 4096 Jan 18 05:51 templates
drwxr-xr-x 1 root root 39 Jan 18 05:55 tenancy
drwxr-xr-x 1 root root 38 Jan 18 05:55 users
drwxr-xr-x 1 root root 38 Jan 18 05:55 utilities
drwxr-xr-x 1 root root 25 Jan 18 05:55 virtualization
drwxr-xr-x 1 root root 25 Jan 18 05:55 wireless
bash-5.1$ cd ./static
bash-5.1$ ls -al
total 7680
drwxr-xr-x 1 root root 31 Jan 24 01:23 .
drwxr-xr-x 1 root root 20 Jan 18 05:54 ..
drwxr-xr-x 6 root root 51 Jan 18 05:55 admin
-rw-r--r-- 1 root root 1133 Jan 18 05:55 cable_trace.css
-rw-r--r-- 1 root root 108636 Jan 18 05:55 config.js
-rw-r--r-- 1 root root 105872 Jan 18 05:55 config.js.map
drwxr-xr-x 4 root root 27 Jan 18 05:55 debug_toolbar
drwxr-xr-x 3 root root 41 Jan 18 05:55 django_tables2
drwxr-xr-x 18 root root 4096 Jan 18 05:55 docs
drwxr-xr-x 5 root root 193 Jan 18 05:55 drf-yasg
drwxr-xr-x 2 root root 25 Jan 18 05:55 graphene_django
-rw-r--r-- 1 root root 27564 Jan 18 05:55 graphiql.css
-rw-r--r-- 1 root root 960413 Jan 18 05:55 graphiql.js
-rw-r--r-- 1 root root 914093 Jan 18 05:55 graphiql.js.map
drwxr-xr-x 3 root root 16 Jan 18 05:55 graphiql_debug_toolbar
-rw-r--r-- 1 root root 1235 Jan 18 05:55 graphql.ico
-rw-r--r-- 1 root root 109291 Jan 18 05:55 lldp.js
-rw-r--r-- 1 root root 106584 Jan 18 05:55 lldp.js.map
-rw-r--r-- 1 root root 465188 Jan 18 05:55 materialdesignicons-webfont-2ZY4X5WS.woff
-rw-r--r-- 1 root root 1026176 Jan 18 05:55 materialdesignicons-webfont-EH3JD4GG.ttf
-rw-r--r-- 1 root root 325244 Jan 18 05:55 materialdesignicons-webfont-KSYPMDN6.woff2
-rw-r--r-- 1 root root 1026396 Jan 18 05:55 materialdesignicons-webfont-LWDVGUDX.eot
drwxr-xr-x 2 root root 4096 Jan 18 05:55 mptt
-rw-r--r-- 1 root root 374410 Jan 18 05:55 netbox-dark.css
-rw-r--r-- 1 root root 286568 Jan 18 05:55 netbox-external.css
-rw-r--r-- 1 root root 232175 Jan 18 05:55 netbox-light.css
-rw-r--r-- 1 root root 727867 Jan 18 05:55 netbox-print.css
-rw-r--r-- 1 root root 1174 Jan 18 05:55 netbox.ico
-rw-r--r-- 1 root root 374821 Jan 18 05:55 netbox.js
-rw-r--r-- 1 root root 344331 Jan 18 05:55 netbox.js.map
-rw-r--r-- 1 root root 835 Jan 18 05:55 netbox_icon.svg
-rw-r--r-- 1 root root 2257 Jan 18 05:55 netbox_logo.png
-rw-r--r-- 1 root root 4719 Jan 18 05:55 netbox_logo.svg
-rw-r--r-- 1 root root 4054 Jan 18 05:55 netbox_touch-icon-180.png
drwxr-xr-x 6 1000 1000 173 Jan 24 01:23 nextbox_ui_plugin
-rw-r--r-- 1 root root 1511 Jan 18 05:55 rack_elevation.css
-rw-r--r-- 1 root root 878 Jan 18 05:55 rest-api.ico
drwxr-xr-x 7 root root 63 Jan 18 05:55 rest_framework
-rw-r--r-- 1 root root 129226 Jan 18 05:55 status.js
-rw-r--r-- 1 root root 128409 Jan 18 05:55 status.js.map
-rw-r--r-- 1 root root 109 Jan 18 05:55 tint_20.png
bash-5.1$ cd ./nextbox_ui_plugin
bash-5.1$ dir
bash: dir: command not found
bash-5.1$ ls -al
total 256
drwxr-xr-x 6 1000 1000 173 Jan 24 01:23 .
drwxr-xr-x 1 root root 31 Jan 24 01:23 ..
-rw-r--r-- 1 1000 1000 81084 Jan 24 01:14 bootstrap.bundle.min.js
-rw-r--r-- 1 1000 1000 155758 Jan 24 01:14 bootstrap.min.css
-rw-r--r-- 1 1000 1000 1504 Jan 24 01:14 button_utils.js
drw-r--r-- 2 1000 1000 27 Jan 24 01:23 img
drw-r--r-- 2 1000 1000 33 Jan 24 01:23 jquery
drw-r--r-- 2 1000 1000 30 Jan 24 01:23 jquery-ui-1.12.1
-rw-r--r-- 1 1000 1000 14227 Jan 24 01:14 next_app.js
drw-r--r-- 6 1000 1000 70 Jan 24 01:23 next_sources
bash-5.1$ chmod 755 ./next_app.js
chmod: ./next_app.js: Operation not permitted
bash-5.1$ sudo chmod 755 ./next_app.js
bash: sudo: command not found

在收集静态文件时,由于权限,我遇到了另一个失败。

收集静态文件

[root@localhost ~]# docker exec -it 534a7d1fe0bf /bin/bash
bash-5.1$ /opt/netbox/venv/bin/python3 manage.py collectstatic
loaded config '/etc/netbox/config/configuration.py'
loaded config '/etc/netbox/config/extra.py'
loaded config '/etc/netbox/config/logging.py'
loaded config '/etc/netbox/config/plugins.py'

You have requested to collect static files at the destination
location as specified in your settings:

/opt/netbox/netbox/static
This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "/opt/netbox/netbox/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line
utility.execute()
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
collected = self.collect()
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
handler(path, prefixed_path, storage)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 338, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 291, in delete_file
self.storage.delete(prefixed_path)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/files/storage.py", line 318, in delete
os.remove(name)
PermissionError: [Errno 13] Permission denied: '/opt/netbox/netbox/static/nextbox_ui_plugin/bootstrap.bundle.min.js'`

bash-5.1$ cd /opt/netbox/netbox/
bash-5.1$ python3 manage.py collectstatic
loaded config '/etc/netbox/config/configuration.py'
loaded config '/etc/netbox/config/extra.py'
loaded config '/etc/netbox/config/logging.py'
loaded config '/etc/netbox/config/plugins.py'

You have requested to collect static files at the destination
location as specified in your settings:

/opt/netbox/netbox/static
This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "/opt/netbox/netbox/manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 419, in execute_from_command_line
utility.execute()
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/init.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 187, in handle
collected = self.collect()
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
handler(path, prefixed_path, storage)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 338, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "/opt/netbox/venv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 291, in delete_file
self.storage.delete(prefixed_path)
File "/opt/netbox/venv/lib/python3.9/site-packages/django/core/files/storage.py", line 318, in delete
os.remove(name)
PermissionError: [Errno 13] Permission denied: '/opt/netbox/netbox/static/nextbox_ui_plugin/bootstrap.bundle.min.js

如您所见,COPY 未能更改 nextbox_ui_plugin 中文档的权限,我想这是关键问题,但我找不到答案。

在stackoverflow中搜索后,我发现netbox没有可用的答案,并且它的docker参与插件很少见。我不知道如何更改他们的权限以再次尝试。现在没有任何效果。

能否请你帮忙?

多谢 :)

4

1 回答 1

0

尝试删除 DOckerfile 中该行的 chown 和 chmod

复制 ./nextbox_ui_plugin/static/nextbox_ui_plugin /opt/netbox/netbox/static/nextbox_ui_plugin

于 2022-02-15T21:53:44.143 回答