Hi @Thom_Hehl and welcome in the MongoDB Community
!
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