# Docker image for MongoDB

**URL:** <https://forums.percona.com/t/docker-image-for-mongodb/6981>\
**Category:** Percona Server for MongoDB\
**Created:** [April 24, 2019, 4:46pm UTC](https://forums.percona.com/t/docker-image-for-mongodb/6981 "2019-04-24T16:46:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sqrl](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@sqrl](https://forums.percona.com/u/sqrl)\
**Post date:** [April 24, 2019, 4:46pm UTC](https://forums.percona.com/t/docker-image-for-mongodb/6981/1 "2019-04-24T16:46:16Z")

</div>

Hi Guys,  
I am currently looking at percona and mongodb enterprise. I am wanting to test the docker image supplied at dockerhub and test the encryption at rest functionality as well as some other functions.

I am trying to find all the options I can pass the image at runtime I can see the examples in the dockerhub page like  
–storageEngine=RocksDB so this looks like I can simply pass mongo.conf parameters to the image is this correct.

so would enabling encryption be as simple as --enableEncryption=True etc. has anyone set this up via the docker image I cant see a list of all options so if you can point me to the documentation that would be great.

---

<div class="post-metadata">

**Author:** ![Vinodh\_Krishnaswamy](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/vinodh_krishnaswamy/32/46_2.png) [@Vinodh\_Krishnaswamy](https://forums.percona.com/u/Vinodh_Krishnaswamy)\
**Post date:** [April 25, 2019, 5:07am UTC](https://forums.percona.com/t/docker-image-for-mongodb/6981/2 "2019-04-25T05:07:26Z")

</div>

Hi sqrl,

> [@](#):
>
> > so would enabling encryption be as simple as --enableEncryption=True etc. has anyone set this up via the docker image I cant see a list of all options so if you can point me to the documentation that would be great.

You could pass the arguments for mongod in docker while setting up the container like you pass arguments to mongod in command prompt usually. For example, to run the mongodb with encryption, you need PSMDB 3.6.8 or more. So you can do the following:

```auto
docker pull percona/percona-server-mongodb:3.6.10
docker run -it --rm percona/percona-server-mongodb:3.6.10 mongod --help

```

The above command will show you the list of arguments available for you to pass in mongod. If you want encryption, then you need to pass the key file as well for the mongod and also the key idea here for encryption is to keep the data encrypted and in separate partition. So you can map the local partition with docker partition as well. I have shown you a simple example below to start a database:

```auto
docker run -d -v /Users/vinodhkrish/docker/key/:/mongodb/key -v /Users/vinodhkrish/docker/data:/mongodb/data --name psmdb36 -p 27020:27020 percona/percona-server-mongodb:3.6.10 mongod --port 27020 --enableEncryption --encryptionKeyFile /mongodb/key/mongodb.key --logpath /var/log/mongodb.log --logappend --dbpath /mongodb/data

```

And check the instance started:

```auto
$ docker exec -it psmdb36 mongo localhost:27020 --eval "db.adminCommand( { getCmdLineOpts: 1 } )"
Percona Server for MongoDB shell version v3.6.10-3.0
connecting to: mongodb://localhost:27020/test?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("0475753c-6c21-40fd-820f-cbcb4dc82fdc") }
Percona Server for MongoDB server version: v3.6.10-3.0
{
"argv" : [
"mongod",
"--port",
"27020",
"--enableEncryption",
"--encryptionKeyFile",
"/mongodb/key/mongodb.key",
"--logpath",
"/var/log/mongodb.log",
"--logappend",
"--dbpath",
"/mongodb/data",
"--bind_ip_all"
],
"parsed" : {
"net" : {
"bindIpAll" : true,
"port" : 27020
},
"security" : {
"enableEncryption" : true,
"encryptionKeyFile" : "/mongodb/key/mongodb.key"
},
"storage" : {
"dbPath" : "/mongodb/data"
},
"systemLog" : {
"destination" : "file",
"logAppend" : true,
"path" : "/var/log/mongodb.log"
}
},
"ok" : 1
}

```

Hope this helps you!

Regards,  
Vinodh Krish

---

<div class="post-metadata">

**Author:** ![Marco\_Cardinali](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/marco_cardinali/32/2560_2.png) [@Marco\_Cardinali](https://forums.percona.com/u/Marco_Cardinali)\
**Post date:** [January 15, 2021, 10:00pm UTC](https://forums.percona.com/t/docker-image-for-mongodb/6981/3 "2021-01-15T22:00:43Z")

</div>

I m not able to set permissions on the key, because if I set something less 600 I receive the error too open when I run the container. If I set 600 I receive an error it can’t read the file…

Would you help me? it seems I should start the container with the proper user
