Skip to content

Instantly share code, notes, and snippets.

@KonstantinKlepikov
Last active July 12, 2022 18:57
Show Gist options
  • Save KonstantinKlepikov/b45792fe49a3ceb401377de727f6d652 to your computer and use it in GitHub Desktop.
Save KonstantinKlepikov/b45792fe49a3ceb401377de727f6d652 to your computer and use it in GitHub Desktop.
mongodb minimal docker compose
ROOT_USERNAME=root
ROOT_PASSWORD=example
ADMINUSERNAME=root
ADMINPASSWORD=example
version: '3.8'
services:
mongo:
image: mongo
restart: always
env_file:
- .env
ports:
- 8082:27017
environment:
MONGO_INITDB_ROOT_USERNAME: ${ROOT_USERNAME?Variable not set}
MONGO_INITDB_ROOT_PASSWORD: ${ROOT_PASSWORD?Variable not set}
mongo-express:
image: mongo-express
restart: always
env_file:
- .env
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: ${ADMINUSERNAME?Variable not set}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${ADMINPASSWORD?Variable not set}
ME_CONFIG_MONGODB_URL: mongodb://${ADMINUSERNAME?Variable not set}:${ADMINPASSWORD?Variable not set}@mongo:27017/
#! /usr/bin/env sh
# Exit in case of error
set -e
docker-compose \
-f docker-compose.yml \
config > docker-stack.yml
docker-compose -f docker-stack.yml build
docker-compose -f docker-stack.yml down --remove-orphans # Remove possibly previous broken stacks left hanging after an error
docker-compose -f docker-stack.yml up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment