Mongodb-org-server.postinst: systemctl: not found

I am following the directions here: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/

I am attempting to create a docker image based on the openjdk image and wish to install a mongdb server there, which I’m using internally to manage temporary databases.

I wanted to make sure what I was running, so I ran cat /etc/os-release in my image, and it displayed the following data:

NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

When I get to the command apt-get install -y mongodb-org I get the following error

Done.
/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

I searched for the error, including this forum, and couldn’t find it, so I’m posting here. Please advise.

Thanks.

Hi @Thom_Hehl and welcome in the MongoDB Community :muscle: !

Usually Docker images are as small as possible so most of the time, they only embed what is absolutely necessary for them to work.

systemctl is not part of the OpenJDK image you are trying to use apparently (makes sense to me) which is required for MongoDB installed by the package manager because it would configure MongoDB to start automatically when your computer starts, etc. Which doesn’t make sense in a Docker container.

So a few advises:

  • it’s weird to install MongoDB in another existing image. The entire philosophy of Docker is to keep things separated and clean. You are doing the exact opposite here.
  • You probably want to run your Java program and communicate with MongoDB. I would do this by connecting the docker containers together with docker network or with docker-compose.
  • There is already a MongoDB image available.
  • If you are still up to the challenge, I would definitely use the MongoDB tarball instead of the package manager to install the MongoDB binaries. But I would use the package manager for the dependencies.

Cheers,
Maxime.

1 Like