This extremely simple docker compose file starts a container running MongoDB 3.2. It is ideal when running local Sitecore development instances that requires a MongoDB.
- Docker v17.06.0 or later - Download here
- Docker has to be set for Linux containers
- Open Powershell or other command line as admin in ./containers/mongo/3.2/
- Run > $ docker-compose up
- Wait for container to start
To support multiple development instances on the same machine you can use a dedicated MongoDB instance for each.
Note: it is not required to have multiple MongoDBs to support multiple Sitecore development instances as long as you ensure the collection names in connectionstrings.config are unique The common naming convention is: {instance_name}_{collection name}
- Make a copy of the folder /containers/solr/bitnami-6.6-sitecore and name it according to the development instance
- Rename the container by editing the docker-compose.yml file and change localhost port
version: "3.3"
services:
{new name}:
image: mongo:3.2
container_name: "mongodb-3.2"
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- data:/data/db
ports:
- {localhost port}:27017
command: mongod --smallfiles --logpath=/dev/null --quiet
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
volumes:
data:
- Open the folder in Powershell or other cmd ling and run > $ docker-compose up
- Edit /App_Config/connectionstrings.config
<?xml version="1.0" encoding="utf-8"?>
<connectionStrings>
...
<add name="analytics" connectionString="mongodb://localhost:{localhost port}/{instance_name}_analytics" />
<add name="tracking.live" connectionString="mongodb://localhost:{localhost port}/{instance_name}_tracking_live" />
<add name="tracking.history" connectionString="mongodb://localhost:{localhost port}/{instance_name}_tracking_history" />
<add name="tracking.contact" connectionString="mongodb://localhost:{localhost port}/{instance_name}_tracking_contact" />
</connectionStrings>
Suggested convention;
Copy the folder to your solution version control repo ex. ~/containers/mongodb/
Remember to add the {folder}/data/db dir to your VC ignore file (.gitignore/.tfignore)
Anders Laub @Laub+Co
Feedback and comments welcome contact me