I am trying to run a Singularity container for MongoDB on a remote server in background mode.
The recipe file that I used to build the mongo.sif is:
Bootstrap: docker
From: mongo:4.4.11
%startscript
exec /usr/bin/mongo "$@"
Further, I have created a data/db directory on the server to be used by the MongoDB instance.
Finally, I run the container, on the server, in the background mode by the following command:
singularity instance start --bind $PWD/data/db:/data/db mongo.sif mongo_1
And, the singularity instance list shows that the instance is up:
However, I don't think so that the mongodb server is running. The command: "lsof -i:27017" shows that the port is free. Mongodb server should have been running here.
Moreover, if I try to connect to the mongo shell by using either of the commands below, I get the same error.
singularity exec --bind $PWD/data/db:/data/db instance://mongo_1 mongo
singularity exec --bind $PWD/data/db:/data/db mongo.sif mongo
I have tried, after starting mongo_1, using the run command: "singularity run --bind $PWD/data/db:/data/db instance://mongo_1". However, this starts the mongo server in the foreground mode.
If I wanted foreground mode, I would simply use "singularity run --bind $PWD/data/db:/data/db mongo.sif" such that MongoDB server runs. I am looking for doing the same thing but, in the background mode.
You may try this:
singularity run instance://mongo_1