【发布时间】:2021-07-22 10:11:04
【问题描述】:
我创建了一个基于 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 已按照 dokefile 中的说明进行安装。我不知道如何摆脱这个错误。
包含 systemctl 的文件 server_install.sh 的行:
sudo systemctl daemon-reload
sudo systemctl restart gearman-job-server.service
【问题讨论】:
-
在大多数情况下,
systemctl在 Docker 中根本不起作用。我会避免在容器中安装 Systemd(它非常重量级且具有侵入性),以及 git(关于凭据和更新存在一些操作问题)和 sudo(在 Docker 中是不必要的),以及大多数运行容器的路径都没有使用.bashrc文件。你能不使用安装程序手动安装软件,并将CMD设置为前台进程运行(不使用systemctl或任何类型的init系统)? -
感谢您的回复。我纠正了你所建议的事情,它奏效了。它应该是用安装程序安装的,但这并不是所有这些中最大的问题。
标签: docker dockerfile systemctl