How to use Container MongoDB with volume shared

Hi,

I want to use the MongoDB Container with store the data outside the container.

To install the Container, I have use the documentation : Install MongoDB Community with Docker - MongoDB Manual v7.0

docker run --name mongodb -p 27017:27017 -d mongodb/mongodb-community-server:latest

Until this point, all works correctly.

Now I tried to run this following commande :

docker run --name mongodb -p 27017:27017 -v /database:/data/db -d mongodb/mongodb-community-server:latest

The container does not start. Why ? What I need to use the container as explain upside.

Regards
Olivier

To get help is always better to share more information.

In this, I assume you got error messages. Please share.

Please share you docker volume definition.

Hi,

In the docker logs mongodb, I have found this error :
{“error”:“boost::filesystem::create_directory: Permission denied [system:13]: "/data/db/journal"”}

Now I have found the solution, to start the Mongodb Container.

I use the commande :
# docker run --name mongodb **-u $UID** -p 27017:27017 -v /databases/:/data/db/ -d mongodb/mongodb-community-server:latest

1 Like