Run PostgreSQL and MongoDB Locally with Docker and GUI Access
DevOps

Run PostgreSQL and MongoDB Locally with Docker and GUI Access

Sagar Yenkure
August 20th, 2025

🐳 Run PostgreSQL & MongoDB Locally with Docker (Plus GUI Access)

Setting up databases locally can be a real pain. You deal with installation headaches, port conflicts, config issues… you name it. But with Docker, it's as easy as running a few commands. In this post, we’ll set up PostgreSQL and MongoDB in your development environment using Docker — and the best part? You’ll get full GUI access through pgAdmin and Mongo Express.


What You’ll Need

  • Docker Desktop installed and running
  • Basic command line knowledge
  • 5 minutes of your time 😎

Project Setup

Let’s keep both PostgreSQL and MongoDB in one Docker Compose file so you can manage them together.

mkdir docker-databases && cd docker-databases touch docker-compose.yml
Click to Copy

🔸 Part 1: PostgreSQL + pgAdmin

PostgreSQL is a robust relational database, and pgAdmin is the most popular GUI for managing it.

docker-compose.yml (PostgreSQL section)

services: postgres: image: postgres:15 container_name: postgres_container environment: POSTGRES_USER: admin POSTGRES_PASSWORD: admin123 POSTGRES_DB: mydb ports: - "5432:5432" volumes: - postgres_data:/var/lib/postgresql/data pgadmin: image: dpage/pgadmin4 container_name: pgadmin_container environment: PGADMIN_DEFAULT_EMAIL: admin@local.com PGADMIN_DEFAULT_PASSWORD: admin123 ports: - "5050:80" depends_on: - postgres
Click to Copy

Access pgAdmin GUI

  1. Open browser → http://localhost:5050
  2. Login:
    • Email:
      admin@local.com
      Click to Copy
    • Password:
      admin123
      Click to Copy
  3. Add new server:
    • Name:
      Local PostgreSQL
      Click to Copy
    • Host:
      postgres
      Click to Copy
    • Port:
      5432
      Click to Copy
    • Username:
      admin
      Click to Copy
    • Password:
      admin123
      Click to Copy

Connect via Prisma (example)

datasource db { provider = "postgresql" url = "postgresql://admin:admin123@localhost:5432/mydb" }
Click to Copy

🔸 Part 2: MongoDB + Mongo Express

MongoDB is a flexible NoSQL document database, and Mongo Express gives us a simple web UI to inspect it.

docker-compose.yml (MongoDB section)

mongodb: image: mongo:6 container_name: mongodb_container ports: - "27017:27017" volumes: - mongodb_data:/data/db mongo-express: image: mongo-express container_name: mongo_express_container ports: - "8081:8081" environment: ME_CONFIG_MONGODB_SERVER: mongodb ME_CONFIG_MONGODB_ADMINUSERNAME: root ME_CONFIG_MONGODB_ADMINPASSWORD: example depends_on: - mongodb
Click to Copy

Access Mongo Express GUI

  • Open browser → http://localhost:8081
  • Collections and databases are auto-listed. No login setup required by default.

Connect via Mongoose (example)

mongoose.connect('mongodb://root:example@localhost:27017/')
Click to Copy

Enable Persistent Data

We’ve included volumes in our Docker Compose to make sure your data doesn’t vanish when containers are restarted:

volumes: postgres_data: mongodb_data:
Click to Copy

To wipe all data (like a fresh install):

docker-compose down -v
Click to Copy

Run Everything

Start all containers together:

docker-compose up -d
Click to Copy

Stop everything:

docker-compose down
Click to Copy

Final Thoughts

That’s it! You now have PostgreSQL + pgAdmin and MongoDB + Mongo Express running locally with zero system pollution. Whether you're building APIs, prototyping fullstack apps, or just exploring, this setup is fast, visual, and easy to manage.

Bonus Ideas:

  • Add Redis or MySQL to the stack
  • Use .env files for secrets
  • Mount custom SQL or JS seed scripts
  • Dockerize your backend and connect to these databases

Happy coding & containerizing! 🐳💻