MongoDB inside Docker Container

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ม.ค. 2025

ความคิดเห็น • 127

  • @arthurpaiva3979
    @arthurpaiva3979 4 ปีที่แล้ว +13

    One of the greatest tutorials I've ever seen. Thank you!

  • @jimmykaushal9982
    @jimmykaushal9982 ปีที่แล้ว +63

    if someone is seeing the error bash: mongo: command not found after "docker exec -it mymongo bash" then once in cotainer run mongosh instead of mongo because The mongo shell is removed from MongoDB 6.0. The replacement is mongosh.

    • @parhamm1
      @parhamm1 ปีที่แล้ว

      thanks

    • @penguinbloopers
      @penguinbloopers ปีที่แล้ว

      thanks a lot for this.

    • @yusharthsingh1185
      @yusharthsingh1185 ปีที่แล้ว

      The problem is there's no tutorial as such for the latest mongos even on official Mongo Documentation.

    • @akshatjain-se6uy
      @akshatjain-se6uy ปีที่แล้ว

      thank you so much 🙏

    • @NghiLam-bn3eh
      @NghiLam-bn3eh 3 หลายเดือนก่อน

      thanks

  • @izmarsel
    @izmarsel ปีที่แล้ว +1

    ¡Gracias!

  • @mauriciosouza1394
    @mauriciosouza1394 4 หลายเดือนก่อน +1

    Para quem é br, e não conseguiu executar o comando mongo em 3:25, utilize o comando mongosh... 😉

  • @DLBrown4
    @DLBrown4 5 ปีที่แล้ว +9

    Well done. Exactly what I was looking for.

    • @mafiacodes
      @mafiacodes  5 ปีที่แล้ว

      Subscribe like share 😊

  • @ghassenbarkache1676
    @ghassenbarkache1676 ปีที่แล้ว

    thanks for the video !! I have problem while running docker for crAPI
    container crapi-community error
    when I run docker logs crapi-community
    I receive this error
    Sad!! .env file not found
    2023/06/08 02:54:22 connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed.
    can you help me to fix this please ?

  • @ManoharReddy-pl4gr
    @ManoharReddy-pl4gr 2 ปีที่แล้ว +1

    After pulling the mongodb image.
    When i enter mongo in bash it says "mongo command line not found"

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      need to have mongoldb installed locally to run mongo commands, else ssh into your container and run mongo there.

    • @mardukvassili
      @mardukvassili ปีที่แล้ว

      Execute 'docker exec -it name_mongo_container mongosh'

  • @crazy_vulcan
    @crazy_vulcan 4 ปีที่แล้ว +2

    Simple yet informative instructions on how to quickly set up a MongoDB docker container... Well done

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Thanks subscribe like share 😊

  • @minaamir3056
    @minaamir3056 ปีที่แล้ว +3

    run mongosh instead of mongo if you got an error

  • @SIDAUM-q9m
    @SIDAUM-q9m 3 หลายเดือนก่อน

    when I go inside an conatiner and run mongo command warning is displayed as bash mongo:command not found

  • @vamsikrishna2241
    @vamsikrishna2241 3 ปีที่แล้ว +1

    After run the docker mongo image how can i logged in by using robo 3t ? How can i generate username and password ?

  • @devexpo
    @devexpo 4 ปีที่แล้ว +2

    Awesome tutorial!
    Thank you! :)

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      You might like this also: th-cam.com/video/gChzfhVGqp8/w-d-xo.html

  • @rottinganal
    @rottinganal 4 ปีที่แล้ว +2

    Very nice tutorial, thanks. But I got into one problem on 4:40. While executing the "mongo localhost:2717" command, I got an error -
    ["mongo" is not recognized as an internal or external command, operable program or batch file]
    I checked if the container was running "docker ps", if the detached mod started, tried different ports, tried different terminals - always the same result

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +2

      U need to install mongodb locally to execute the mongo command which will connect to ur docker instance

    • @rottinganal
      @rottinganal 4 ปีที่แล้ว +1

      @@mafiacodes thanks

  • @gnaneshnag3309
    @gnaneshnag3309 2 ปีที่แล้ว

    inside the container if i type mongo not able to get details as shown in the video above video

  • @ennis_w
    @ennis_w 3 ปีที่แล้ว +1

    Thanks for your video.
    Learning docker recently and find the solution of some mistakes.

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      You might like this as well:
      How to dockerize NodeJS and MongoDB application using docker-compose
      th-cam.com/video/vm3YfOHf_Cc/w-d-xo.html

  • @softlogx
    @softlogx 2 หลายเดือนก่อน

    how to get connection string for reacjs project ?

  • @nikhilsharma5233
    @nikhilsharma5233 ปีที่แล้ว

    Can you please help me
    I am running two services mongo and redis in a docker container but for some reason i want to run it locally but after i run on docker even after i stopped the services i still am unable to run mongo locally anymore

  • @FahmidWasif
    @FahmidWasif 4 ปีที่แล้ว +2

    I really loved it. Simple and on the point.
    Thanks a LOT!!!

  • @wm.jayampathiweerasinghe7997
    @wm.jayampathiweerasinghe7997 ปีที่แล้ว

    for windows i used
    PS D:\Docker\mongodb> docker volume create --name=mongodata
    PS D:\Docker\mongodb> docker volume inspect mongodata
    [
    {
    "CreatedAt": "2023-06-19T14:52:32Z",
    "Driver": "local",
    "Labels": {},
    "Mountpoint": "/var/lib/docker/volumes/mongodata/_data",
    "Name": "mongodata",
    "Options": {},
    "Scope": "local"
    }
    ]
    PS D:\Docker\mongodb> docker run -d -p 2717:27017 -v ${PWD}/data:/var/lib/docker/volumes/mongodata/_data --name mymongo mongo:latest

  • @ashique12009
    @ashique12009 9 หลายเดือนก่อน

    Good one but when I enter into container by this command: docker exec -it mymongo bash and then enter mongo command it says me: bash: mongo: command not found.
    Any thoughts on this issue?
    Thanks!

  • @anecdote-jarcoustic
    @anecdote-jarcoustic ปีที่แล้ว

    i have a backend project, do i need to run this in my project folder (path). Or is this just database storage, that can summoned whenever the path my project located ?
    Please 🙏🙏 this is my firstime using docker with mongo, and i have a technical test to be done

  • @chetanchetan-dn4pr
    @chetanchetan-dn4pr ปีที่แล้ว +1

    hello bhai i tried this many times but when i go docker exec -it mymongo bash then type mongo show me bash: mongo: command not found please find solution on it

    • @vovaaa4351
      @vovaaa4351 10 หลายเดือนก่อน +1

      i have same problem, did you fix that?

    • @chetanchetan-dn4pr
      @chetanchetan-dn4pr 10 หลายเดือนก่อน

      bro in a new Mongo container on docker generally use mongosh command try it work@@vovaaa4351

    • @chetanchetan-dn4pr
      @chetanchetan-dn4pr 10 หลายเดือนก่อน

      bro in new docker mongo container mongosh command use @@vovaaa4351

  • @nagupilla8895
    @nagupilla8895 2 ปีที่แล้ว

    thanks for great video.. and just to add now in 2022 dec, @3:25 the command mongo seems to be deco'ed and mongosh works instead.

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      Subscribe like share 👍

  • @yurafedonyuk
    @yurafedonyuk ปีที่แล้ว

    man, you are great!
    Greetings and big thx from Ukrainian developer

  • @saltierthanyou69
    @saltierthanyou69 2 ปีที่แล้ว +1

    It's quick and easy, but technically not really secure. Wish someone would show how to create a really secure MongoDB container.

  • @sanketdarekar8152
    @sanketdarekar8152 3 ปีที่แล้ว

    can vice versa is possible for port mapping from docker container to host machine? Is it possible by pass parameter?

  • @SamuelLenk
    @SamuelLenk 2 ปีที่แล้ว +1

    Great video! Only at minute 3:23 I had "Mongo not found". Now in mongo version 6 it's "mongoDB" instead of "mongo" (-:

    • @OutOfHomeHere
      @OutOfHomeHere 2 ปีที่แล้ว

      now its mongosh to execute mongo shell

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      Thanks and pinned.

    • @johnbenil87
      @johnbenil87 2 ปีที่แล้ว +10

      "mongosh" worked.

  • @TheRagreis
    @TheRagreis 2 ปีที่แล้ว

    Can you help me? When I execute mongo localhost_2717 it tells me command not found... I'm inside ~/MongodbData but this folder is empty...

  • @smithchristian4251
    @smithchristian4251 2 ปีที่แล้ว

    Do I need to install mongo on my machine? If I am running mongo outside of container?

  • @princetanwar5694
    @princetanwar5694 3 ปีที่แล้ว

    Bro which keyboard you have can you give the link to buy

  • @rennygalindez
    @rennygalindez 4 ปีที่แล้ว +2

    Great video, because it's concise!

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Subscribe like share

  • @brogen100
    @brogen100 4 ปีที่แล้ว

    Nice Tutorial. But I got as far as 4:40 . when i executed the command "mongo localhost:2717". I get the error :
    [thread1] Error: network error while attempting to run command 'isMaster' on host 'localhost:2717' :
    connect@src/mongo/shell/mongo.js:237:13
    @(connect):1:6
    exception: connect failed

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +1

      I tried it right away, and its working, u can troubleshoot in a couple of ways:
      1. do "docker info" to get the number of containers running
      2. do "docker container ps" , and see if mongo container is running.
      3. make sure u have started the container in detached mode
      4. make sure ur not using port 2717 on local machine for anything else.
      5. try a different port 2718 on local machine(or any other port which is not used by system or other services)
      6. try a different terminal
      7. try it on a diff pc.

    • @brogen100
      @brogen100 4 ปีที่แล้ว

      @@mafiacodes ty for debug options. The problem was resolved by updating my mongo shell.

    • @brogen100
      @brogen100 4 ปีที่แล้ว +1

      @@mafiacodes Well thanks to your tutorials, I was able to get a mongo docker running. I've decided to go back to native mongo, as docker was intermittently hogging my cpu. Even though I set the docker cpu settings to 1.

    • @varunkumaryella1277
      @varunkumaryella1277 4 ปีที่แล้ว

      @@mafiacodes I am getting same error. Can you please guide how to fix this? C:\Users\PDI\Desktop\GEODIS>mongo localhost:2717
      MongoDB shell version v4.4.3
      connecting to: mongodb://localhost:2717/test?compressors=disabled&gssapiServiceName=mongodb
      Error: couldn't connect to server localhost:2717, connection attempt failed: SocketException: Error connecting to localhost:2717 (127.0.0.1:2717) :: caused by :: No connection could be made because the target machine actively refused it. :
      connect@src/mongo/shell/mongo.js:374:17
      @(connect):2:6
      exception: connect failed
      exiting with code 1

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      See my reply above and see if that makes a fix

  • @DivijShrivastava
    @DivijShrivastava 3 ปีที่แล้ว

    I am getting mongo:command not found. When I am running it by directly going to directory and running mongo localhost:2717 command instead of using docker shell. What can be done in this case?

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      have u installed mongodb locally on your system

    • @DivijShrivastava
      @DivijShrivastava 3 ปีที่แล้ว

      @@mafiacodes no

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Install and then the command will be recognised

  • @isso013
    @isso013 3 ปีที่แล้ว

    When i run it on synology dsm 7 it crashes

  • @djordje1999
    @djordje1999 ปีที่แล้ว

    AVX in VM is a problem.. if can't use latest image i won't use it at all.. quickest dump of learning something as dev ever..

  • @olegmaz3969
    @olegmaz3969 หลายเดือนก่อน

    I only don't know how to run a mongoimport command inside of container. It need to exit from mongosh to do this, but how.
    For example mongoimport tv-shows.json -d movieData -c movies --jsonArray --drop

  • @mandardesai3841
    @mandardesai3841 3 ปีที่แล้ว

    can we have IDE for mongodb to manage query and other stuff ?

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Use mongodb compass

  • @manasjoshi7037
    @manasjoshi7037 2 ปีที่แล้ว

    is it necessary to install mongodb locally for this? because my exec command is not working

    • @chang_vijay
      @chang_vijay ปีที่แล้ว

      i have same problem

  • @rp0000
    @rp0000 10 หลายเดือนก่อน

    Very useful and quick, thanks :)

  • @nivedita_shah
    @nivedita_shah 4 ปีที่แล้ว

    can we access this mongodb from application in other container?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Yes Nivedita you can, and in fact docker containers are meant to be used as separate entities coz every thing is sandboxed into its own environment.

    • @nivedita_shah
      @nivedita_shah 4 ปีที่แล้ว

      @@mafiacodes any video on how to do this? I have containerized my flask application which is using mongo db. I'll create another container for mongo db. but then how to access mongo db in app present in other container

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Use a docker compose file for this
      Here is an example which uses docker compose file for creating a wordpress application.
      Wordpress setup using Docker compose
      th-cam.com/video/Vxf3qtk1qIA/w-d-xo.html

  • @josedominguez7680
    @josedominguez7680 4 ปีที่แล้ว +1

    thanks a lot, really helpful !!

  • @elliottgermanovich3081
    @elliottgermanovich3081 4 ปีที่แล้ว

    I'm having a common issue and I am wondering if it has to do with the Mongo image. the run command you provide works, but if I stop the container and restart, it does not restart. More specifically, it will start and immediately stop. From what I've read it has to do with the fact that there is no running process in the container, and so it stops right away. I'm not sure if I need to create a custom image with Mongo installed on Linux, or if there is some other configuration step that I need to know. Any thoughts?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      afaik this should not happen, u can start and stop a container as many times u want and it should be in the same state as it was on the first start (leaving apart the data)...

  • @jaydeepconsultants
    @jaydeepconsultants ปีที่แล้ว +1

    Life saver !

  • @ashique12009
    @ashique12009 2 ปีที่แล้ว

    Nice, but I can't see my mongo related files which should created for volume in command.
    I did this command: docker run -d -p 2717:27017 -v ~/php_mongodb_projects:/data/db --name mymongo mongo:latest
    As I am in win10 OS, should I write full path of that director?
    Thanks.

    • @mafiacodes
      @mafiacodes  2 ปีที่แล้ว

      yes indeed, you need to provide a full path, I dunno even if windows understand "~" means home dir

    • @ashique12009
      @ashique12009 2 ปีที่แล้ว

      @@mafiacodes as I'm in win10 OS, I've created a volume by below command:
      docker volume create --name=mongodata
      Then I do the below command:
      docker run -d -p 2717:27017 -v mongodata --name mymongo mongo:latest
      So it runs my container normally.
      After that I also checked docker exec -it bash to enter into its bash and create a database and insert a record.
      But the issue is after exit and exit I did the below command:
      mongo localhost:2717
      And I get this error:
      'mongo' is not recognized as an internal or external command,
      operable program or batch file.
      Any hints?
      Thanks.

  • @lioraviv2359
    @lioraviv2359 3 ปีที่แล้ว

    thank you but i need to know how to restore the backup folder to the host, can you please help me? i think it will help the rest of your subs aswell

  • @himesh_89
    @himesh_89 4 ปีที่แล้ว

    what is the default root user id and pwd? in case i want to expose the db to cloud server.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +1

      Mongo db doesn’t have a user password unless u create one in admin db and provide them with roles.

  • @VerdadeTop
    @VerdadeTop 4 ปีที่แล้ว

    Do I need to have Mongo installed in my actual machine also?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      No not at all.

    • @aayushjoglekar8544
      @aayushjoglekar8544 3 ปีที่แล้ว +1

      You'll need to install MongoDB if you wish to access the MongoCLI from your terminal because The CLI utility `mongo` comes along with the mongo installation.

  • @WomboBraker
    @WomboBraker 3 ปีที่แล้ว

    Cheers fam! Helped a brother out

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Subscribe like share

  • @user-mksmstpck
    @user-mksmstpck 3 ปีที่แล้ว +1

    I don't know English perfectly, but i understand all.
    Thanks 👍

  • @nazgulzholmagambetova1198
    @nazgulzholmagambetova1198 3 ปีที่แล้ว +1

    you just saved my life!

  • @himquantum
    @himquantum 5 ปีที่แล้ว +1

    thanks Mittal

  • @Levelord92
    @Levelord92 4 ปีที่แล้ว

    Hi! How do you configure username:password for mongodb container?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      The same way as we do it normally using the mongo shell

  • @michaelofosu-darko4579
    @michaelofosu-darko4579 3 ปีที่แล้ว +1

    Thank you, Sir.

  • @Dipenparmar12
    @Dipenparmar12 2 ปีที่แล้ว

    Inside Docker container Says 'bash: mongo: command not found'

  • @masterincode
    @masterincode 4 ปีที่แล้ว

    How can I connect my local mysql with phpmyadmin?

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว +1

      $ docker pull mysql:8.0.1
      $ docker run --name my-own-mysql -e MYSQL_ROOT_PASSWORD=mypass123 -d mysql:8.0.1
      $ docker pull phpmyadmin/phpmyadmin:latest
      $ docker run --name my-own-phpmyadmin -d --link my-own-mysql:db -p 8081:80 phpmyadmin/phpmyadmin
      Visit : localhost:8081/
      And ur done 😘

    • @masterincode
      @masterincode 4 ปีที่แล้ว +1

      @@mafiacodes really appreciated your quick response , also I got it running without pulling MySQL , as my local had MySQL already.

    • @mafiacodes
      @mafiacodes  4 ปีที่แล้ว

      Great

    • @masterincode
      @masterincode 4 ปีที่แล้ว

      You justified your channel name👍

  • @farzadsole3784
    @farzadsole3784 5 ปีที่แล้ว +1

    Thank you for the tutorial :)
    Would be possible to do the same tutorial using dockerfile
    Cheers

    • @mafiacodes
      @mafiacodes  5 ปีที่แล้ว

      Well Dockerfiles are used to build your own images and here we are using the mongodb image itself and not changing it, but I guess you wanna know how to use mongodb inside docker-compose, is that so?

    • @farzadsole3784
      @farzadsole3784 5 ปีที่แล้ว

      @@mafiacodes Yes, correct :)

  • @olegmaz3969
    @olegmaz3969 2 หลายเดือนก่อน

    Thanks a lot :)

  • @allenbina5611
    @allenbina5611 4 ปีที่แล้ว +1

    the path that starts with ~ is a relative path from your home directory. an absolute path is from /

  • @NhoMienTrung
    @NhoMienTrung 2 ปีที่แล้ว +1

    Thank!

  • @nicholaswhite7351
    @nicholaswhite7351 10 หลายเดือนก่อน

    Thanx a lot!!!!!!

  • @acronproject
    @acronproject ปีที่แล้ว

    Thanks

  • @akashsalunkhe5685
    @akashsalunkhe5685 2 ปีที่แล้ว

    very helpful

  • @Zerowolrd
    @Zerowolrd 5 ปีที่แล้ว +1

    Thank you :)

    • @mafiacodes
      @mafiacodes  5 ปีที่แล้ว

      😊 subscribe like share

  • @izakjs
    @izakjs 4 ปีที่แล้ว +1

    TY MEN

  • @humbertosuriano5667
    @humbertosuriano5667 4 ปีที่แล้ว +3

    me sirve

  • @leonardomartinez6433
    @leonardomartinez6433 4 ปีที่แล้ว +3

    me gusteishion

  • @edgarramos8194
    @edgarramos8194 4 ปีที่แล้ว +2

    me sirveishon

  • @question_mark
    @question_mark 3 ปีที่แล้ว

    lesgoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

  • @kheeee8793
    @kheeee8793 2 ปีที่แล้ว

    wtf

  • @javiergutierrez2958
    @javiergutierrez2958 4 ปีที่แล้ว +2

    wapo

  • @II-me8dm
    @II-me8dm 3 ปีที่แล้ว

    Видео отличное, но говорит ужс

    • @mafiacodes
      @mafiacodes  3 ปีที่แล้ว

      Спасибо, но я просто хотел, чтобы было легко понять
      Подписаться как поделиться

  • @GROOVETECHSETS
    @GROOVETECHSETS 2 ปีที่แล้ว +1

    NOW IS MONGO SH └─[$] docker exec -it mongodb mongosh