🔧 Docker Setup Guide: MongoDB, pgAdmin4, and File Access Troubleshooting on Windows
🧭 Introduction
This article walks through the practical setup of mongo-express and pgAdmin4 using Docker on Windows. We'll troubleshoot common issues like port conflicts, file upload limitations, and Docker networking quirks, and show how to enable file access between your Windows filesystem and Docker containers.
⚙️ Prerequisites
-
Docker installed on Windows
-
Basic familiarity with Docker CLI and containers
-
Local SQL or backup files you'd like to use inside containers
🧱 Part 1: Setting up MongoDB and Mongo-Express in Docker
✅ 1. Start the MongoDB container
✅ 2. Create a custom Docker network
✅ 3. Run mongo-express with custom credentials and port
Make sure port 8085 or 8086 is not already in use. You can check with:
Then run:
Visit: http://localhost:8086
❌ Issue: Mongo Express Error — Command listDatabases requires authentication
If MongoDB has authentication enabled (e.g., with a root username/password), you must pass that into mongo-express:
Otherwise, you’ll get the MongoServerError: Command listDatabases requires authentication.
🧱 Part 2: Running PostgreSQL and pgAdmin4
✅ 1. Start the PostgreSQL container
✅ 2. Create a network (if not already created)
✅ 3. Start pgAdmin4 with port 8081
Access: http://localhost:8081
❌ Problem: “Unable to connect to server: [Errno -3] Try again”
This usually means pgAdmin cannot resolve the hostname postgres.
✅ Fix:
Make sure both containers are on the same Docker network and use the container name postgres in pgAdmin connection settings (not localhost).
Check networks:
If containers already show up there, you’re good. If not, connect them manually:
🗂️ Part 3: Enabling File Uploads in pgAdmin (Query Tool)
❌ Problem: “Click the folder icon — but it’s empty”
This happens because Docker containers can’t access Windows filesystem unless a volume is mounted.
✅ Option 1: Copy files directly into the container
Replace admin_admin.com with your actual user folder in pgAdmin storage.
✅ Option 2: Mount Windows folder into pgAdmin container
This is the preferred method if you want continuous access to local .sql or .backup files.
-
Stop and remove existing pgAdmin container:
-
Create a local folder for pgAdmin storage:
-
Run pgAdmin with volume mount:
Now when you click the folder icon in the Query Tool or Restore dialog, you’ll see your .sql files.
🛠️ Additional Tips
-
Reset a container:
If you need to start over, run: -
Check container logs:
For debugging: -
Use Docker Compose:
For production or more complex setups, consider using adocker-compose.ymlfile.
✅ Conclusion
With proper port assignments, Docker networks, and mounted volumes, you can easily run database tools like mongo-express and pgAdmin4 locally with full access to your Windows files. This setup is lightweight and ideal for dev/test environments.
Comments
Post a Comment