Skip to content

Instantly share code, notes, and snippets.

@Wavefarer42
Created January 22, 2019 10:04
Show Gist options
  • Save Wavefarer42/9486fb03a1425398be3091f320d23a06 to your computer and use it in GitHub Desktop.
Save Wavefarer42/9486fb03a1425398be3091f320d23a06 to your computer and use it in GitHub Desktop.
MongoDB Charts (docker-compose)
version: "3.3"
services:
mongo:
image: mongo:4.1.1
restart: on-failure
command: --wiredTigerCacheSizeGB 3
ports:
# Charts db is available under port 27018 to not block the default mongo port
- "8082:8081"
- "27018:27017"
volumes:
- ./data/db:/data/db
charts:
image: quay.io/mongodb/charts:v0.11.0
hostname: charts
ports:
# host:container port mapping. If you want MongoDB Charts to be
# reachable on a different port on the docker host, change this
# to <port>:80, e.g. 8888:80.
- 80:80
- 443:443
volumes:
- ./data/keys:/mongodb-charts/volumes/keys
- ./data/logs:/mongodb-charts/volumes/logs
- ./data/db-certs:/mongodb-charts/volumes/db-certs
- ./data/web-certs:/mongodb-charts/volumes/web-certs
environment:
# The presence of following 2 environment variables will enable HTTPS on Charts server.
# All HTTP requests will be redirected to HTTPS as well.
# To enable HTTPS, upload your certificate and key file to the web-certs volume,
# uncomment the following lines and replace with the names of your certificate and key file.
# CHARTS_HTTPS_CERTIFICATE_FILE: charts-https.crt
# CHARTS_HTTPS_CERTIFICATE_KEY_FILE: charts-https.key
# This environment variable controls the built-in support widget and
# metrics collection in MongoDB Charts. To disable both, set the value
# to "off". The default is "on".
CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"
# Directory where you can upload SSL certificates (.pem format) which
# should be considered trusted self-signed or root certificates when
# Charts is accessing MongoDB servers with ?ssl=true
SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
CHARTS_MONGODB_URI: mongodb://172.17.0.1:27018
networks:
- backend
networks:
backend:
volumes:
keys:
logs:
db-certs:
web-certs:
@Wavefarer42
Copy link
Author

Quick local test docker-compose configuration of mongo db charts.

@Avik1993
Copy link

thanks for this.
But I am not able to login after creating user in mongodb charts container using 'charts-cli'.
It throws (TRANSPORT_ERROR): the request transport encountered an error communicating with Stitch: Network request failed
Any idea how to resolve this?

@Avik1993
Copy link

It seems like MongoDB Charts isn't able to handle internal routing if it is exposed to ports other than 80 or 443.

@Wavefarer42
Copy link
Author

Sorry, the gist was only a reminder and is based on the documentation (i think), but Mongo Charts was not up for task, so I haven't used it.
Do not think that I encountered this error thou.

@divyang4481
Copy link

if i expose docker in ngnix behind /mongochart it is failing to load javascript and css

@afboteros
Copy link

How "hostname" property should be used? i was guessing it would set the server uri on javascript connections to backend of MongoDB Charts, but when i try to login it shows an error:

(TRANSPORT_ERROR): the request transport encountered an error communicating with Stitch: Network request failed

I am deploying the docker on an ubuntu server behind nginx with https, proxy passing to 8080 port which was already binded on docker-compose file to port 80 of container.

@asherAbecasiss
Copy link

asherAbecasiss commented Dec 9, 2023


version: "3.3"

services:
  mongo:
    image: mongo:4.1.1
    container_name: mongotest
    restart: on-failure
    command: --wiredTigerCacheSizeGB 3
    ports:

      - "8082:8081"
      - "27017:27017"
    volumes:
      - ./data/db:/data/db

  charts:
    image: quay.io/mongodb/charts:v0.11.0
    hostname: charts
    ports:

      - 80:80
      
    volumes:
      - ./data/keys:/mongodb-charts/volumes/keys
      - ./data/logs:/mongodb-charts/volumes/logs
      - ./data/db-certs:/mongodb-charts/volumes/db-certs
      - ./data/web-certs:/mongodb-charts/volumes/web-certs
    environment:

      CHARTS_SUPPORT_WIDGET_AND_METRICS: "on"

      SSL_CERT_DIR: /mongodb-charts/volumes/db-certs
      CHARTS_MONGODB_URI: mongodb://mongotest:27017


volumes:
  keys:
  logs:
  db-certs:
  web-certs:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment