如何解决Docker 与 systemctl
我创建了一个基于 Ubuntu 20.04 的 dockerfile,它更改 .bashrc 并从 github 克隆存储库并开始安装。 (在存储库中存在安装程序的文件 server_install.sh。)
Dockerfile:
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 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 的安装如 docefile 中所述。我不知道如何摆脱这个错误。
包含 systemctl 的文件 server_install.sh 的行:
sudo systemctl daemon-reload
sudo systemctl restart gearman-job-server.service
解决方法
所有 docker RUN 脚本都将在您无法控制 PID 1 的容器中启动。它实际上是您尝试在其中执行的脚本。如果它是另一个服务,那么在每个 stp 中启动/停止进程有时会很有帮助。
RUN dbctl start ; execdb -c "CREATE USER"; dbctl stop
有一种解决方法是使用 docker-systemctl-replacement 脚本拦截 systemctl 执行,并且还可以根据需要启动/停止所需的服务。这允许您在容器中运行面向 VM 的“server_install”(无需修补)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。