构建mongo映像时找不到systemctl [英] systemctl not found while building mongo image
问题描述
我正在尝试根据官方图像构建mongo 4.4图像Dockerfile ,但是我遇到了找不到systemctl的问题.映像本身有一行可以在安装后将其删除,但不确定其来源.有什么想法吗?
I am trying to build a mongo 4.4 image based on the official image Dockerfile but I am running into an issue with systemctl not found. The image itself has a line to remove it after setup, but not sure where it came from. Any ideas?
Setting up mongodb-org-database-tools-extra (4.4.0) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Setting up libkrb5support0:amd64 (1.16-2ubuntu0.1) ...
Setting up krb5-locales (1.16-2ubuntu0.1) ...
Setting up libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ...
Setting up libk5crypto3:amd64 (1.16-2ubuntu0.1) ...
Setting up libkrb5-3:amd64 (1.16-2ubuntu0.1) ...
Setting up libgssapi-krb5-2:amd64 (1.16-2ubuntu0.1) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Setting up mongodb-database-tools (100.1.1) ...
Setting up mongodb-org-mongos (4.4.0) ...
Setting up mongodb-org-tools (4.4.0) ...
Setting up mongodb-org-server (4.4.0) ...
/var/lib/dpkg/info/mongodb-org-server.postinst: 43: /var/lib/dpkg/info/mongodb-org-server.postinst: systemctl: not found
dpkg: error processing package mongodb-org-server (--configure):
installed mongodb-org-server package post-installation script subprocess returned error exit status 127
Setting up mongodb-org-shell (4.4.0) ...
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.
dpkg: error processing package mongodb-org (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Errors were encountered while processing:
mongodb-org-server
mongodb-org
[91mE: Sub-process /usr/bin/dpkg returned an error code (1)
[0mThe command '/bin/sh -c set -x && export DEBIAN_FRONTEND=noninteractive && apt-get update && echo "mongodb-org hold" | dpkg --set-selections && echo "mongodb-org-server hold" | dpkg --set-selections && echo "mongodb-org-shell hold" | dpkg --set-selections && echo "mongodb-org-mongos hold" | dpkg --set-selections && echo "mongodb-org-tools hold" | dpkg --set-selections && apt-get install -y ${MONGO_PACKAGE}=$MONGO_VERSION ${MONGO_PACKAGE}-server=$MONGO_VERSION ${MONGO_PACKAGE}-shell=$MONGO_VERSION ${MONGO_PACKAGE}-mongos=$MONGO_VERSION ${MONGO_PACKAGE}-tools=$MONGO_VERSION && rm -f /usr/local/bin/systemctl && rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/mongodb && mv /etc/mongod.conf /etc/mongod.conf.orig' returned a non-zero code: 100
推荐答案
FL3SH回答有效,但为了更有效地传达含义,您可以创建从/bin/systemctl
到/的符号链接bin/true
.
FL3SH answer works but to convey the meaning more effectively you can create a symbolic link from /bin/systemctl
to /bin/true
.
/bin/true
是一条始终返回0(shell的真实值)的命令,因此它不会失败.这是表明您要返回true的标准方法.另请参见此SO帖子
/bin/true
is a command wich always return 0 (the truthy value of the shell) so it does not fail. It's a standard way to indicate that you want to return true. See this SO post also
您需要在Dockerfile中添加的命令是:
The command you need to add in the Dockerfile is:
RUN ln -s /bin/true /usr/local/bin/systemctl
或
RUN ln -s /bin/true /bin/systemctl
结果是您通过调用/bin/true
而不是/bin/systemctl
The effect is that you trick the post-install script by calling /bin/true
instead of /bin/systemctl
您可以在mongodb官方 Dockerfile 4.4第91行 haytham与他的描述有关.
You can find the same trick into the official mongodb Dockerfile 4.4 line 91 that haytham linked in his description.
/bin/echo
与/bin/true
一样好,因为echo也返回0.您可以尝试做
/bin/echo
works as well as /bin/true
because echo returns 0 as well. You can try it by doing
echo "test"
echo $?
您将看到0作为第二个 echo
的结果.
And you'll see 0 as the result of the second echo
.
这篇关于构建mongo映像时找不到systemctl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!