首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker with systemctl

Docker with systemctl
EN

Stack Overflow用户
提问于 2021-07-22 18:11:04
回答 1查看 132关注 0票数 0

我创建了一个基于Ubuntu20.04的dockerfile,用于更改.bashrc并从github克隆存储库并启动安装。(在存储库中存在安装程序的server_install.sh文件。)

Dockerfile:

代码语言:javascript
复制
FROM ubuntu:20.04  
USER root  
LABEL maintainer="zarooba"  
ENV TZ=Europe/Warsaw  
ENV DEBIAN_FRONTEND=noninteractive   
ADD aamks_bashrc.txt /root  
RUN touch /root/.bashrc && cat /root/aamks_bashrc.txt >> /root/.bashrc  
RUN apt-get update  
RUN apt-get install -y python3  
RUN apt-get install -y git  
WORKDIR /usr/local  
RUN git clone https://github.com/aamks/aamks.git  
RUN ["chmod", "+x", "/usr/local/aamks/installer/server_install.sh"]  
RUN apt-get update -y && \  
    apt-get -y install sudo && \  
    apt-get install -y systemd   
CMD /usr/local/aamks/installer/server_install.sh 

安装开始了,一切正常,但在安装过程中的某一点上有一个bug:

代码语言:javascript
复制
Bug with systemctl: System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

systemctl按照dockefile中所述进行安装。我不知道如何摆脱这个bug。

包含systemctl的文件server_install.sh行:

代码语言:javascript
复制
sudo systemctl daemon-reload
sudo systemctl restart gearman-job-server.service
EN

回答 1

Stack Overflow用户

发布于 2021-08-05 18:55:17

所有docker运行脚本都将在一个容器中启动,在该容器中您无法控制PID 1。实际上,它是您尝试在其中执行的脚本。如果它是另一个服务,那么有时在每个stp中启动/停止进程是很有帮助的。

代码语言:javascript
复制
RUN dbctl start ; execdb -c "CREATE USER"; dbctl stop

使用docker-systemctl-replacement脚本可以解决此问题,该脚本可以截获systemctl执行,并且还可以根据需要启动/停止所需的服务。这允许您在容器中运行面向VM的"server_install“(无需为其打补丁)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68483021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档