<commit_before># MongoDB for OpenShift - Docker images

This repository contains Dockerfiles for MongoDB images for OpenShift.
Users can choose between RHEL and CentOS based images.

### Versions

Currently supported version of MongoDB:

* mongodb-2.4

Currently supported version of RHEL:

* RHEL7

Currently supported version of CentOS:

* CentOS7


## Installation
Choose between CentOS7 or RHEL7 based image:

*  **RHEL7 based image**

	To build a rhel7-based image, you need to run Docker build on a properly subscribed RHEL machine.

	```console
	git clone https://github.com/openshift/mongodb.git
	cd mongodb
	make build TARGET=rhel7
	```

*  **CentOS7 based image**

	This image is also available on DockerHub. To download it use:

	```console
	docker pull openshift/mongodb-24-centos7
	```	

	To build MongoDB image from scratch use: 

	```console
	git clone https://github.com/openshift/mongodb.git
	cd mongodb
	make build
	```

## 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.

|    Variable name          |    Description                              |   Default  |
| :------------------------ | -----------------------------------------   | ---------- |
|  `MONGODB_USERNAME`           | User name for MONGODB account to be created |
|  `MONGODB_PASSWORD`       | <PASSWORD>               |
|  `MONGODB_DATABASE`       | Database name (optional)                    | production |
|  `MONGODB_ADMIN_PASSWORD` | Password for the admin <PASSWORD> (optional)      |

You can also set following mount points by passing `-v /host:/container`
flag to Docker.

|  Volume mount point    | Description            |
| :--------------------- | ---------------------- |
|  `/var/lib/mongodb/`   | MongoDB data directory |


### Usage

We will assume that you are using the `openshift/mongodb-24-centos7`
image. Suppose that you want to set only mandatory required environment
variables and store the database in the `/home/user/database`
directory on the host filesystem, you need to execute the following
command:

```console
docker run -d -e MONGODB_USERNAME=<user> -e MONGODB_PASSWORD=<password> -v /home/user/database:/var/lib/mongodb openshift/mongodb-24-centos7
```

If you are initializing the database and it's the first time you are using the
specified shared volume, the database will be created, together with database
administrator user and also MongoDB admin user if `MONGODB_ADMIN_PASSWORD`
environment variable is specified. After that the MongoDB daemon will be
started.
If you are re-attaching the volume to another container the creation of the
database user and the admin user will be skipped and only the mongodb
daemon will be started.


### MongoDB admin user
The admin user is not set by default. You can create one by setting
`MONGODB_ADMIN_PASSWORD` environment variable, in which case the admin 
user name will be set to `admin`. This process is done upon initializing <commit_msg>Updated README.md docker run command after requiring database env var<commit_after># MongoDB for OpenShift - Docker images

This repository contains Dockerfiles for MongoDB images for OpenShift.
Users can choose between RHEL and CentOS based images.

### Versions

Currently supported version of MongoDB:

* mongodb-2.4

Currently supported version of RHEL:

* RHEL7

Currently supported version of CentOS:

* CentOS7


## Installation
Choose between CentOS7 or RHEL7 based image:

*  **RHEL7 based image**

	To build a rhel7-based image, you need to run Docker build on a properly subscribed RHEL machine.

	```console
	git clone https://github.com/openshift/mongodb.git
	cd mongodb
	make build TARGET=rhel7
	```

*  **CentOS7 based image**

	This image is also available on DockerHub. To download it use:

	```console
	docker pull openshift/mongodb-24-centos7
	```

	To build MongoDB image from scratch use:

	```console
	git clone https://github.com/openshift/mongodb.git
	cd mongodb
	make build
	```

## 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.

|    Variable name          |    Description                              |   Default  |
| :------------------------ | -----------------------------------------   | ---------- |
|  `MONGODB_USERNAME`           | User name for MONGODB account to be created |
|  `MONGODB_PASSWORD`       | <PASSWORD>               |
|  `MONGODB_DATABASE`       | Database name (optional)                    | production |
|  `MONGODB_ADMIN_PASSWORD` | Password for the admin user (optional)      |

You can also set following mount points by passing `-v /host:/container`
flag to Docker.

|  Volume mount point    | Description            |
| :--------------------- | ---------------------- |
|  `/var/lib/mongodb/`   | MongoDB data directory |


### Usage

We will assume that you are using the `openshift/mongodb-24-centos7`
image. Suppose that you want to set only mandatory required environment
variables and store the database in the `/home/user/database`
directory on the host filesystem, you need to execute the following
command:

```console
docker run -d -e MONGODB_USERNAME=<user> -e MONGODB_PASSWORD=<password> -e MONGODB_DATABASE=<database> -v /home/user/database:/var/lib/mongodb openshift/mongodb-24-centos7
```

If you are initializing the database and it's the first time you are using the
specified shared volume, the database will be created, together with database
administrator user and also MongoDB admin user if `MONGODB_ADMIN_PASSWORD`
environment variable is specified. After that the MongoDB daemon will be
started.
If you are re-attaching the volume to another container the creation of the
database user and the admin user will be skipped and only the mongodb
daemon will be started.


### MongoDB admin user
The admin user is not set by default. You can create one by setting
`MONGODB_ADMIN_PASSWORD` environment variable, in which case the admin
user name will be set to `admin`. This process is done upon initializing
{'fraction_non_alphanumeric': 0.10569897710667316, 'fraction_numerical': 0.0061698327650592626, 'mean_word_length': 3.0052015604681404, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7400420', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1671, 'n_words': 717}