anchor.diff:  toc::[]
   
   == Overview
  -The OpenShift https://github.com/openshift/mongodb/tree/master[MongoDB] image repository contains the sources and Dockerfiles for building various versions of MongoDB images.
  +The OpenShift https://github.com/openshift/mongodb/tree/master[MongoDB] image
  +repository contains the sources and Dockerfiles for building various versions of
  +MongoDB images.
   
   == Versions
   Currently, OpenShift only supports version https://github.com/openshift/mongodb/tree/master/2.4[2.4] of MongoDB.
   
   == Base Images
   
  +The following base images are currently available:
  +
   * RHEL-7
   * CentOS-7
   
   [NOTE]
   ====
  -In order to perform build or test action on a RHEL-7 based MongoDB image, you need to run the build on properly subscribed RHEL-7 machine.
  +In order to perform build or test action on a RHEL-7 based MongoDB image, you
  +need to run the build on properly subscribed RHEL-7 machine.
   ====
   
   == Installation
  -To build MongoDB image, select either a RHEL7 or CentOS7 base image:
  -
  -=== RHEL-7 Base Image
  -
  -----
  -$ git clone https://github.com/openshift/mongodb.git
  -$ cd mongodb
  -$ make build TARGET=rhel7 VERSION=2.4
  -----
  -
  -=== CentOS-7 Base Image
  -
  -This image is also available on DockerHub. To download it use:
  -
  -----
  -docker pull openshift/mongodb-24-centos7
  -----
  -
  -To build MongoDB image from scratch use:
  -
  -----
  -$ git clone https://github.com/openshift/mongodb.git
  -$ cd mongodb
  -$ make build VERSION=2.4
  -----
  -
  -[NOTE]
  -====
  -If you omit the `VERSION` parameter, the build/test action is performed on all supported versions of MongoDB. Since version `2.4` is the only version supported, you can omit this parameter.
  +To build a MongoDB image, use one of the following procedures, depending on your
  +base image:
  +
  +*RHEL-7 Base Image*
  +
  +To build a RHEL-7 based MongoDB image:
  +
  +. Clone the following repository:
  ++
  +****
  +`$ git clone https://github.com/openshift/mongodb.git`
  +****
  +. Navigate into the directory you just created:
  ++
  +****
  +`$ cd mongodb`
  +****
  +. Build the image:
  ++
  +****
  +`$ make build TARGET=rhel7 VERSION=2.4`
  +****
  +
  +*CentOS-7 Base Image*
  +
  +This image is available on DockerHub. To download it:
  +
  +****
  +`$ docker pull openshift/mongodb-24-centos7`
  +****
  +
  +Alternatively, you can build a CentOS-7 based MongoDB image:
  +
  +. Clone the following repository:
  ++
  +****
  +`$ git clone https://github.com/openshift/mongodb.git`
  +****
  +. Navigate into the directory you just created:
  ++
  +****
  +`$ cd mongodb`
  +****
  +. Build the image:
  ++
  +****
  +`$ make build VERSION=2.4`
  +****
  +
  +[NOTE]
  +====
  +If you omit the `VERSION` parameter, then the build/test action is performed on
  +all the supported versions of MongoDB. Currently, only version 2.4 is supported,
  +so you can omit this parameter.
   ====
   
   
   == Usage
   
  -=== Environment variables
  -
  -The image recognizes following environment variables that you can set
  -during initialization, by passing `-e VAR=VALUE` to the Docker run
  -command.
  +To create a container running MongoDB, you need to run following commands.
  +
  +*RHEL 7 Base Image*
  +
  +****
  +`docker run -d -e MONGODB_USERNAME=_<user>_ -e MONGODB_PASSWORD=_<password>_ -e MONGODB_DATABASE=_<database>_  openshift/mongodb-24-rhel7`
  +****
  +
  +*CentOS 7 Base Image*
  +
  +****
  +`docker run -d -e MONGODB_USERNAME=_<user>_ -e MONGODB_PASSWORD=_<password>_ -e MONGODB_DATABASE=_<database>_  openshift/mongodb-24-centos7`
  +****
  +
  +== Testing
  +
  +This repository also provides a test framework which checks basic functionality of the MongoDB image.
  +
  +Select whether the MongoDB image you are testing is RHEL-based or CentOS-based.
  +
  +*RHEL-7 Base Image*
  +
  +To test a RHEL-7-based MongoDB image, run the test on a properly subscribed RHEL machine.
  +
  +. Navigate into the *_mongodb_* directory:
  ++
  +****
  +`$ cd mongodb`
  +****
  +. Test the image:
  ++
  +****
  +`$ make test TARGET=rhel7 VERSION=2.4`
  +****
  +
  +*CentOS-7 Base Image*
  +
  +To test a CentOS-7-based MongoDB image:
  +
  +. Navigate into the *_mongodb_* directory:
  ++
  +****
  +`$ cd mongodb`
  +****
  +. Test the image:
  +****
  +`$ make test VERSION=2.4`
  +****
  +
  +[NOTE]
  +====
  +If you omit the `VERSION` parameter, then the build/test action is performed on all supported versions of MongoDB. Since only version 2.4 is currently supported, you can omit this parameter.
  +====
  +
  +== Shared Volumes
  +
  +To set only mandatory required environment variables, and store the database in the shared *_/home/user/database_* directory on the host, execute the following command:
  +
  +****
  +`docker run -d -e MONGODB_USERNAME=_<user>_ -e MONGODB_PASSWORD=_<password>_ -e MONGODB_DATABASE=_<database>_ -v /home/user/database:/var/lib/mongodb openshift/_<image>_`
  +****
  +
  +=== Initializing Database
  +
  +The first time you use the shared volume and initialize the database, the
  +database is created along with the database administrator user and the MongoDB
  +root user (if you specify the `*MONGODB_ADMIN_PASSWORD*` environment variable).
  +Afterwards, the MongoDB daemon starts up. If you are re-attaching the volume to
  +another container, then the database user and the administrator user are not
  +created, and the MongoDB daemon starts.
  +
  +== MongoDB Commands in Running Containers
  +
  +OpenShift uses https://www.softwarecollections.org/[Software Collections] to
  +install and launch MongoDB. If you want to execute a MongoDB command
  +inside of a running container (for debugging), you must prefix it with the `scl enable mongodb24` command.
  +
  +
  +To execute MongoDB commands inside the container:
  +
  +****
  +`$ scl enable mongodb24 -- mongo _<db_name>_ -u _<username>_ -p _<password>_`
  +****
  +
  +To execute a command inside a running container from the host:
  +
  +****
  +`$ docker exec -it _<CONTAINER_ID>_ scl enable mongodb24 /bin/bash`
  +****
  +
  +[NOTE]
  +====
  +In this case, you are able to run MongoDB commands without invoking the scl
  +commands.
  +====
  +
  +== Environment Variables
  +
  +The image recognizes the following environment variables that you can set
  +during initialization with this command:
  +
  +****
  +`$ docker run -e VAR=_<variable>_`
  +****
   
   .Repository Organization
   [cols="4a,6a",options="header"]
  
positive.code: |Volume mount point |Description
  
  |`/var/lib/mongodb/`
  |MongoDB data directory
  |===
  
  MongoDB settings can be configured by additional environment variables.
  
  .Additional MongoDB settings
  [cols="3a,6a,1a",options="header"]
  
negative.code: 
  |Variable name |Description
  
  |`*MONGODB_USERNAME*`
  |User name for MongoDB account to be created.
  
  |`*MONGODB_PASSWORD*`
  |Password for the user account.
  
  |`*MONGODB_DATABASE*`
  |Database name.
  
  |`*MONGODB_ROOT_PASSWORD*`
  |Password for the root user. (optional)
  |===
  
  *Volume Mount Points*
  
  You can set volume mount points with the following command:
  
  ****
  `$ docker run -v /_<host>_:/_<container>_`
  ****
  
  .Volumes
  [cols="3a,3a",options="header"]
  