MongoDB containers with Docker Compose
Docker Compose facilitates spinning up a container for the MongoDB database without installing MongoDB locally.
Prerequisites
- Docker Compose installed
Configuration
The following configuration spins up the MongoDB container with the UI tool (Mongo Express).
The connection string for the MongoDB database is mongodb://localhost:27018
.
Mongo Express is available at the http://localhost:8082
link. Use the below Basic auth credentials to log in to Mongo Express.
# docker-compose.ymlversion: '3.8'services:mongo:image: 'mongo:7.0.5'ports:- 27018:27017volumes:- my-data:/var/lib/mongodb/datamongo-express:image: 'mongo-express:1.0.2'ports:- 8082:8081environment:ME_CONFIG_BASICAUTH_USERNAME: usernameME_CONFIG_BASICAUTH_PASSWORD: passwordvolumes:my-data:
Run the following command to spin up the containers.
docker-compose up
Course
Build your SaaS in 2 weeks - Start Now