Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
MongoDB docker container doesn't show databases

I setup MongoDB docker container following this blog: https://medium.com/@kristaps.strals/docker-mongodb-net-core-a-good-time-e21f1acb4b7b

and when I run .net core app, save one todo, I manage to query it back, and it seems that everything works (todo collection is created, db is created, todo is saved). But when I access mongo db container using 'docker exec -it mongodb bash' and try to get dbs with 'show dbs' it retrieves empty list. Also, this docker compose boots up mongo express container which also doesn't list new db and collection. Do you know what can be an issue?

Cheers

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's likely that you have authentication enabled (username and password). This means that you have to first authenticate in the shell before you can list the databases.

Here's how that can be done (extra steps added for googlers):

    $ docker ps // list images

    IMAGE
    my-mongodb-container

$ docker exec -it my-mongodb-container bash

// -it is a flag for 'interactive terminal', bash is the shell we'll use

root@example:/# mongo 
// enter mongodb shell

> use admin 
// switched to db admin

> db.auth("username", "password");
// 1

> show dbs
admin  0.000GB
config 0.000GB
local  0.000GB
mydb   0.000GB

> use mydb
// switched to db mydb

You are now able to run mongodb shell commands inside your mongodb instance - so things like 'show collections' will work.

Hope that helps someone! This stuff is sometimes very opaque :)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!