Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save guillecro/d727382ab6e4f0a4e8657beb760bb41e to your computer and use it in GitHub Desktop.

Select an option

Save guillecro/d727382ab6e4f0a4e8657beb760bb41e to your computer and use it in GitHub Desktop.
Running MongoDB Compass 1.28.x (or lower) in Docker (Ubuntu 24.04+)

Running MongoDB Compass 1.28.4 in Docker (Ubuntu 24.04)

This guide walks you through installing and running MongoDB Compass 1.28.4 inside a Docker container, with GUI support, and connected to a MongoDB 3.6 container on Ubuntu 24.04 LTS.


Why this setup?

  • Compass 1.28.4 is one of the last versions that supports MongoDB 3.6.
  • Ubuntu 24.04 no longer includes libgconf-2-4, which Compass depends on.
  • Docker allows isolating these older dependencies.

πŸ—„ Step 1: Run MongoDB 3.6 Container

mkdir -p ~/databases/mongo3.6

docker run -d --name mongo3.6 \
  -p 27017:27017 \
  -v ~/databases/mongo3.6:/data/db \
  mongo:3.6

You can connect to this MongoDB instance via the Docker bridge network using 172.17.0.1 as the host.


🧰 Step 2: Build Docker Image for Compass 1.28.4

Lets put a Dockerfile in a folder

$ mkdir $HOME/mongodbcompass1284
$ cd $HOME/mongodbcompass1284

Create a file named Dockerfile with the following contents:

$ nano Dockerfile
FROM debian:bullseye

ENV DEBIAN_FRONTEND=noninteractive

# Install dependencies
RUN apt-get update && apt-get install -y \
    curl ca-certificates \
    libgtk-3-0 libxss1 libasound2 libnss3 libx11-xcb1 libxcomposite1 libxdamage1 libxrandr2 \
    libatk1.0-0 libatk-bridge2.0-0 libx11-6 libxcb1 libxext6 libxfixes3 \
    && rm -rf /var/lib/apt/lists/*

# Download and install MongoDB Compass 1.28.4 .deb
RUN curl -L -o /tmp/compass.deb https://downloads.mongodb.com/compass/mongodb-compass_1.28.4_amd64.deb \
    && apt-get update && apt-get install -y /tmp/compass.deb \
    && rm /tmp/compass.deb

# Entry point for Compass
ENTRYPOINT ["mongodb-compass", "--no-sandbox"]

Then build the Docker image:

docker build -t compass-1284 .

πŸ–Ό Step 3: Enable X11 Forwarding on Host

Make sure X11 apps from Docker can use your display:

xhost +local:docker

πŸš€ Step 4: Run Compass Container with GUI Support

docker run -it --rm \
  -e DISPLAY=$DISPLAY \
  -v /tmp/.X11-unix:/tmp/.X11-unix \
  compass-1284

MongoDB Compass should open! Now, try to connect, not to localhost, but to where your mongo is.

Then in Compass, connect to:

mongodb://172.17.0.1:27017

This IP is the default gateway from the container to the host (Docker bridge network).


βœ… Summary

This setup lets you use legacy MongoDB Compass 1.28.4 on modern systems, fully isolated, with GUI and network connectivity to MongoDB 3.6 running on the Docker host.

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