Public Repository

Last pushed: 24 days ago
Short Description
Percona Server for MongoDB docker images
Full Description

What is Percona Server for MongoDB?

Percona Server for MongoDB® is a free, enhanced, fully compatible, open source, drop-in replacement for the MongoDB® Community Edition that includes enterprise-grade features and functionality.

For more information and related downloads for Percona Server and other Percona products, please visit http://www.percona.com.

Percona Server for MongoDB Docker Images

These are experimental Percona Server for MongoDB Docker images, created and maintained by the Percona team. The image has the Percona Fractal Tree based storage engine PerconaFT, RocksDB and WiredTiger enabled. The available versions are:

Percona Server for MontoDB 3.0.8 (tag: 3.0)

Images are updated when new releases are published.

How to Use the Images

Start a Percona Server for MongoDB Instance

Start a Percona Server for MongoDB container as follows:

docker run --name container-name  -d percona/percona-server-mongodb:tag

Where container-name is the name you want to assign to your container and tag is the tag specifying the version you want. See the list above for relevant tags, or look at the full list of tags.

Connect to Percona Server from an Application in Another Docker Container

This image exposes the standard MongoDB port (27017), so container linking makes the instance available to other containers. Start other containers like this in order to link it to the Percona Server for MongoDB container:

docker run --name app-container-name --link container-name -d app-that-uses-mongodb

Connect to Percona Server for MongoDB from the MongoDB Command Line Client

The following command starts another container instance and runs the mongo command line client against your original container, allowing you to execute SQL statements against your database:

docker run -it --link container-name --rm percona/percona-server-mongodb:tag mongo -h container-name

where container-name is the name of your database container.

Notes, Tips, Gotchas

Where to Store Data

There are many two ways to store data used by applications that run in Docker containers. We maintain our usual stance and encourage users to investigate the options and use the method that best suits their use case. Here are some of the options available:

  • Let Docker manage the storage of your database data by writing the database files to disk on the host system using its own internal volume management. The current solutions, devicemapper, aufs and overlayfs have negative performance records.
  • Create a data directory on the host system (outside the container on high performance storage) and mount this to a directory visible from inside the container. This places the database files in a known location on the host system, and makes it easy for tools and applications on the host system to access the files. The user needs to make sure that the directory exists, and that permissions and other security mechanisms on the host system are set up correctly.

The Docker documentation is a good starting point for understanding the different storage options and variations, and there are multiple blog and forum postings that discuss and give advice in this area. We will simply show the basic procedure here for the latter option above:

  1. Create a data directory on a suitable volume on your host system, e.g. /local/datadir.
  2. Start your container like this:
    docker run --name container-name -v /local/datadir:/data/db -d percona/percona-server-mongodb:tag

The -v /local/datadir:/data/db part of the command mounts the /local/datadir directory from the underlying host system as /data/db inside the container, where MongoDB by default will write its data files.

Port forwarding

Docker allows mapping of ports on the container to ports on the host system by using the -p option. If you start the container as follows, you can connect to the database by connecting your client to a port on the host machine. This can greatly simplfy consolidating many instances to a single host. In this example port 6603, the we use the address of the Docker host to connect to the TCP port the Docker deamon is forwarding from:

docker run --name container-name `-p 6603:3306` -d percona/percona-server-mongodb
mongo docker_host_ip:6603

Passing options to the server

You can pass arbitrary command line options to the MySQL server by appending them to the run command:

docker run --name my-container-name -d percona/percona-server-mongodb --option1=value --option2=value

In this case, the values of option1 and option2 will be passed directly to the server when it is started. The following command will for instance start your container with RocksDB storage engine:

docker run --name container-name -d  percona/percona-server-mongodb --storageEngine=RocksDB

Supported Docker Versions

These images are officially supported by the MySQL team on Docker version 1.9. Support for older versions (down to 1.0) is provided on a best-effort basis, but we strongly recommend running on the most recent version, since that is assumed for parts of the documentation above.

User Feedback

We welcome your feedback!

Docker Pull Command
Owner
percona

Comments (4)
denji
8 months ago

More info for mmapv1, wiredTiger, rocksdb, inMemory:

denji
8 months ago

RocksDB → case-sensitive: rocksdb.

docker-compose.yml

version: '2'
services:
  mongodb:
    image: 'percona/percona-server-mongodb'
    # (case sensitive) engine: mmapv1, rocksdb, wiredTiger, inMemory
    command: --storageEngine=rocksdb
    #volumes:
    # - /storage/mongodb-ps:/data/db

Attempted to create a lock file on a read-only directory: /data/db, terminating

# Inside Docker
$ id mongodb
uid=1001(mongodb) gid=0(root) groups=0(root)
# Outside of the Host
% chown -vR 1001:0 /storage/mongodb-ps

RocksDB

  • storage.rocksdb.configString
  • RocksDB storage CacheSize: --rocksdbCacheSizeGB (Global: --storageEngineCacheSizeGB).

WiredTiger

  • storage.wiredTiger.collectionConfig.configString (--wiredTigerCollectionConfigString).
  • storage.wiredTiger.engineConfig.configString (--wiredTigerEngineConfigString).
  • storage.wiredTiger.indexConfig.configString (--wiredTigerIndexConfigString).

~PerconaFT~

Deprecated engine

Global options

--setParameters
--setParametersMongos
--storageEngine
--storageEngineCacheSizeGB
--wiredTigerEngineConfigString
--wiredTigerCollectionConfigString
--wiredTigerIndexConfigString
--noJournal
--noJournalPrealloc
--auth
--keyFile
--authUser
--authPassword
--authenticationDatabase
--authMechanism
--adminUser
--adminPassword
--useLegacyConfigServers
--useLegacyReplicationProtocol
--enableMajorityReadConcern
--writeConcernMajorityShouldJournal
--enableEncryption
--encryptionKeyFile
--auditDestination
--minPort
--maxPort
--mongosBinVersion
--shardMixedBinVersions
--networkMessageCompressors
--skipValidationOnInvalidViewDefinitions
--forceValidationWithFeatureCompatibilityVersion

Refs

stkaes
a year ago

Storage engine names seem to be case sensitive:

```docker run -it percona/percona-server-mongodb --storageEngine=rocksdb
````

works.

stkaes
a year ago

I tried running the 3.2.7 version with RocksDB, but I get unknown storage engine.

docker run -it percona/percona-server-mongodb --storageEngine=RocksDB
2016-08-10T12:03:41.398+0000 I STORAGE  [main] [RocksDB] Block Cache Size GB: 0
2016-08-10T12:03:41.398+0000 I STORAGE  [main] [RocksDB] Compression: snappy
2016-08-10T12:03:41.399+0000 I STORAGE  [main] [RocksDB] MaxWriteMBPerSec: 1024
2016-08-10T12:03:41.399+0000 I STORAGE  [main] [RocksDB] Engine custom option: 
2016-08-10T12:03:41.399+0000 I STORAGE  [main] [RocksDB] Crash safe counters: 0
2016-08-10T12:03:41.402+0000 I ACCESS   [main] Initialized External Auth Session
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=e934dcb08bae
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] db version v3.2.7-1.1
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] git version: 3bd0157c170e79dcc91b3a1525facd9eba3c9ba3
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] allocator: tcmalloc
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] modules: none
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] build environment:
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten]     distarch: x86_64
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2016-08-10T12:03:41.404+0000 I CONTROL  [initandlisten] options: { storage: { engine: "RocksDB" } }
2016-08-10T12:03:41.408+0000 I STORAGE  [initandlisten] exception in initAndListen: 18656 Cannot start server with an unknown storage engine: RocksDB, terminating
2016-08-10T12:03:41.408+0000 I CONTROL  [initandlisten] dbexit:  rc: 100