Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重启就挂 #26

Open
helloworldbugs opened this issue Jun 4, 2024 · 6 comments
Open

重启就挂 #26

helloworldbugs opened this issue Jun 4, 2024 · 6 comments

Comments

@helloworldbugs
Copy link

重启docker之后服务就挂了,进容器重新执行脚本bash /root/arl/set.sh报错如下
image

@helloworldbugs
Copy link
Author

用的是第2个全量指纹的docker版本,名为arl-docker-all

@hellowchen
Copy link

加1,同问题解决了吗

@ShallowDream888
Copy link

删除setup_docker.sh中的--privileged=true这个参数后重开一个容器,进入容器后新建一个sh脚本start.sh,输入以下内容

set +e
echo "启动服务 ..."
systemctl enable mongod
systemctl start mongod
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
echo "启动 arl 服务 ..."
systemctl enable arl-web
systemctl start arl-web
systemctl enable arl-worker
systemctl start arl-worker
systemctl enable arl-worker-github
systemctl start arl-worker-github
systemctl enable arl-scheduler
systemctl start arl-scheduler
systemctl enable nginx
systemctl start nginx
systemctl status arl-web
systemctl status arl-worker
systemctl status arl-worker-github
systemctl status arl-scheduler
echo "安装完毕"

chmod +x start.sh赋权后执行,可成功启动

@Github3362
Copy link

删除setup_docker.sh中的--privileged=true这个参数后重开一个容器,进入容器后新建一个sh脚本start.sh,输入以下内容

set +e
echo "启动服务 ..."
systemctl enable mongod
systemctl start mongod
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
echo "启动 arl 服务 ..."
systemctl enable arl-web
systemctl start arl-web
systemctl enable arl-worker
systemctl start arl-worker
systemctl enable arl-worker-github
systemctl start arl-worker-github
systemctl enable arl-scheduler
systemctl start arl-scheduler
systemctl enable nginx
systemctl start nginx
systemctl status arl-web
systemctl status arl-worker
systemctl status arl-worker-github
systemctl status arl-scheduler
echo "安装完毕"

chmod +x start.sh赋权后执行,可成功启动

解决不了
Uploading v.png…

@Github3362
Copy link

[root@7402bffe0b43 arl]# ./start.sh
./start.sh: line 1: et: command not found
启动服务 ...
ERROR:systemctl:the service is already running on PID 334
启动 arl 服务 ...
ERROR:systemctl:Unit arl-web.service not found.
ERROR:systemctl:Unit arl-web.service not found.
ERROR:systemctl:Unit arl-worker.service not found.
ERROR:systemctl:Unit arl-worker.service not found.
ERROR:systemctl:Unit arl-worker-github.service not found.
ERROR:systemctl:Unit arl-worker-github.service not found.
ERROR:systemctl:Unit arl-scheduler.service not found.
ERROR:systemctl:Unit arl-scheduler.service not found.
ERROR:systemctl:Unit arl-web.service could not be found.

ERROR:systemctl:Unit arl-worker.service could not be found.

ERROR:systemctl:Unit arl-worker-github.service could not be found.

ERROR:systemctl:Unit arl-scheduler.service could not be found.

@hanshou101
Copy link

删除setup_docker.sh中的--privileged=true这个参数后重开一个容器,进入容器后新建一个sh脚本start.sh,输入以下内容

set +e
echo "启动服务 ..."
systemctl enable mongod
systemctl start mongod
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
echo "启动 arl 服务 ..."
systemctl enable arl-web
systemctl start arl-web
systemctl enable arl-worker
systemctl start arl-worker
systemctl enable arl-worker-github
systemctl start arl-worker-github
systemctl enable arl-scheduler
systemctl start arl-scheduler
systemctl enable nginx
systemctl start nginx
systemctl status arl-web
systemctl status arl-worker
systemctl status arl-worker-github
systemctl status arl-scheduler
echo "安装完毕"

chmod +x start.sh赋权后执行,可成功启动

按照【层主的办法】,已经重新启动成功了。

AI是这样分析的:


这是一个很好的问题。让我来解释一下这个情况的原因和解决方案:

1. 问题原因:
   
   这个问题主要与Docker容器的权限和系统服务管理有关。ARL灯塔服务可能使用了systemd来管理其内部服务,而systemd在Docker容器中的运行是受限的。

2. --privileged=true 参数的作用:

   这个参数给予容器几乎与宿主机相同的权限。它允许容器访问所有设备,并且可以修改一些系统设置。这在某些情况下是必要的,但也可能带来安全风险。

3. 为什么第一次启动正常,重启后出问题:

   第一次启动时,容器可能使用了特权模式初始化了一些服务。重启后,如果没有特权模式,这些服务可能无法正常启动或重新初始化。

4. 移除 --privileged=true 后为什么能解决问题:

   移除这个参数后,容器被迫使用更安全、更标准的方式来管理服务。这可能导致ARL灯塔服务采用了不依赖systemd的替代方案来启动和管理其内部服务。

5. 建议的解决方案:

   a. 移除 --privileged=true 参数,使用更安全的配置。
   b. 如果服务确实需要某些特权,考虑只给予必要的权限,而不是完全的特权模式。
   c. 检查ARL灯塔服务的文档,看是否有推荐的Docker配置。

6. 最佳实践:

   - 尽量避免在Docker中使用 --privileged=true,除非绝对必要。
   - 使用更细粒度的权限控制,如 --cap-add 来只添加必要的功能。
   - 考虑使用Docker的用户命名空间映射来增强安全性。

总的来说,移除 --privileged=true 参数迫使服务采用了更标准、更安全的运行方式,这不仅解决了重启问题,还提高了整体的安全性。这是Docker容器化应用的一个常见优化过程。



脚本的作用:
这个脚本手动启动并启用了ARL灯塔服务所需的所有关键组件,包括数据库(MongoDB)、消息队列(RabbitMQ)、Web服务、工作进程、调度器和Web服务器(Nginx)。
为什么需要这个脚本:
当移除 --privileged=true 参数后,容器可能无法自动启动这些服务。这个脚本提供了一种手动方式来确保所有必要的服务都已启动。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants