如何在Pod中运行systemctl [英] How to run systemctl in a pod
问题描述
在Pod中运行systemctl命令时遇到拒绝访问错误.
Getting access denied error while running the systemctl command in a pod.
每当尝试在Pod中启动任何服务(例如MySQL或tomcat服务器)时,都会显示拒绝访问错误.
Whenever try to start any service, for example, MySQL or tomcat server in a pod, it gives access denied error.
有什么方法可以在pod中运行systemctl.
Is there any way by which I can run systemctl within a pod.
推荐答案
这是与Docker有关的问题,而不是与Kubernetes有关的问题. 根据页面在Docker文档中在容器中运行多个服务:
This is a problem related to Docker, not Kubernetes. According to the page Run multiple services in a container in docker docs:
通常建议您通过 每个容器使用一项服务
It is generally recommended that you separate areas of concern by using one service per container
但是,如果您确实要使用流程管理器,则可以尝试 supervisord ,它允许您使用 supervisorctl 命令,类似于 systemctl .上面的页面说明了如何执行此操作:
However if you really want to use a process manager, you can try supervisord, which allows you to use supervisorctl commands, similar to systemctl. The page above explains how to do that:
这是使用此方法的示例Dockerfile,它假定 预先编写的supervisord.conf,my_first_process和my_second_process 所有文件都与Dockerfile位于同一目录中.
Here is an example Dockerfile using this approach, that assumes the pre-written supervisord.conf, my_first_process, and my_second_process files all exist in the same directory as your Dockerfile.
FROM ubuntu:latest
RUN apt-get update && apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY my_first_process my_first_process
COPY my_second_process my_second_process
CMD ["/usr/bin/supervisord"]
这篇关于如何在Pod中运行systemctl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!