Building a Docker image for Mongo BI Connector

Eder Chamalé
2 min readDec 16, 2019

--

Source: https://docs.mongodb.com/bi-connector/master/

Mongo BI Connector is an awesome tool to use your Mongo DB storage as aBusiness Intelligence Cube. If you ran Mongo DB as Docker container maybe you asked how do you run Mongo BI Connector as a container also. Unfortunately there is almost nothing at Docker Hub to run this.

But nothing is lost. You can always build your own image. Here is a simple Dockerfile to achieve this requirement. You should use a mongosqld.conf in order to run Mongo BI Connector successfully.

Dockerfile

FROM ubuntu:18.04
WORKDIR /home/mongobi
RUN apt-get update
RUN apt-get install -y libssl1.0.0 libssl-dev libgssapi-krb5-2 wget
RUN wget https://info-mongodb-com.s3.amazonaws.com/mongodb-bi/v2/mongodb-bi-linux-x86_64-ubuntu1804-v2.13.1.tgz
RUN tar -xvzf mongodb-bi-linux-x86_64-ubuntu1804-v2.13.1.tgz
WORKDIR /home/mongobi/mongodb-bi-linux-x86_64-ubuntu1804-v2.13.1
RUN mkdir /logs
RUN ls
RUN echo $PATH
RUN install -m755 bin/mongo* /usr/local/bin/
EXPOSE 3307
CMD ["mongosqld", "--config=/home/mongobi/mongosqld.conf"]

The packages installed in apt-get command were determined as a trial-error process 😵.

Let’s define some variables, so you can replace with yours when needed:

{{YourLogFolder}}✅ = /home/johndoe/mongobi/logs
{{YourConfFolder}}✅ = /home/johndoe/mongobi/conf
{{YourDockerUser}}✅ = johndoe
{{YourSchemaPath}}✅ = /home/johndoe/mongobi/schema/schema.drdl # IF YOU HAVE, NOT REQUIRED 😋

Now build your image as:

docker build -t ✅{{YourDockerUser}}✅/mongobi .

To run this image first create a log folder, for example:

mkdir ✅{{YourLogFolder}}

And create a mongosqld.conf (for example):

✅{{YourConfFolder}}✅/mongosqld.conf

systemLog:
path: '/logs/mongosqld.log'
verbosity: 10
mongodb:
net:
uri: "mongodb://instance-1:27017,instance-2:27017/?replicaSet=MEDIUM"
#schema:
# path: "✅{{YourSchemaPath}}✅" #If you have an schema please uncomment this line
net:
bindIp: 0.0.0.0
port: 3307

Now, add our service to docker-compose.yml (if you have)

docker-compose.yml

version: "3"
services:
# ... MORE SERVICES ...
mongo-bi:
image: ✅{{YourDockerUser}}✅/mongobi
restart: always
volumes:
#- "✅{{YourSchemaPath}}✅:/home/mongobi/schema.drdl" #Uncomment if you have an schema file
- "✅{{YourConfFolder}}✅/mongosqld.conf:/home/mongobi/mongosqld.conf"
- "✅{{YourLogFolder}}✅:/logs"
container_name: "mongo-bi"
hostname: "mongo-bi"
ports:
- "3307:3307"

Let’s run our container (using our docker-compose.yml path):

docker-compose up -d

Test if your container is running:

tail -f -n 25 ✅{{YourLogFolder}}✅/mongosqld.log

The output should be similar to:

2019-12-16T18:14:16.404+0000 I CONTROL    [initandlisten] mongosqld starting: version=v2.13.1 pid=1 host=mongo-bi
2019-12-16T18:14:16.404+0000 I CONTROL [initandlisten] git version: bae9ae2a9bff80642215b648d46312804fe62f2d
2019-12-16T18:14:16.404+0000 I CONTROL [initandlisten] OpenSSL version OpenSSL 1.1.1 11 Sep 2018 (built with OpenSSL 1.1.1 11 Sep 2018)
2019-12-16T18:14:16.404+0000 I CONTROL [initandlisten] options: {config: "/home/mongobi/mongosqld.conf", systemLog: {path: "/logs/mongosqld.log", verbosity: 10}, schema: {path: "/home/mongobi/schema.drdl"}, net: {bindIp: [0.0.0.0]}, mongodb: {net: {uri: "mongodb://instance-0:27017,instance-1:27017/?replicaSet=NeROUTE", auth: {source: "admin"}}}}
2019-12-16T18:14:16.404+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for mongosqld.
2019-12-16T18:14:16.404+0000 I CONTROL [initandlisten]
2019-12-16T18:14:16.413+0000 I NETWORK [initandlisten] waiting for connections at [::]:3307
2019-12-16T18:14:16.413+0000 I NETWORK [initandlisten] waiting for connections at /tmp/mysql.sock

And voilà, it is running as a container. 🤩

You can find this image in Docker Hub: docker pull juky/mongobi

--

--