Score:1

How to install Mongodb in a docker container and use it?

cn flag

I'm using Ubuntu 22.04 LTS, as of Oct 2022 ubuntu 22.04 is not supported by Mongodb team completely, So I'm struggling with it as I need mongodb-org installed for my work. So my question is, Is there anyway I can install mongodb in a docker container and use it??? I don't know much about docker if anyone knows how can I achieve this that will be really appreciated.

in flag
Yes, you can. Mongo has [an official Docker repository](https://hub.docker.com/_/mongo) that you can pull images from. If you are running Ubuntu Desktop, then you can [follow these instructions](https://docs.docker.com/engine/install/ubuntu/) to install everything you need
Score:0
vn flag

If you have Docker installed, run the following to start a MongoDB server:

docker run -d --name MongoDB -p 27017:27017 mongo:latest

Mapping the port will allow you to use the MongoDB port directly on the host IP.

It's also possible to start a stack with Mongo Express. Create the following mongo-stack.yml

# Use root/example as user/password credentials
version: '3.1'

services:

  mongo:
    image: mongo:latest
    restart: always
    ports:
      - 27017:27017
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: example

  mongo-express:
    image: mongo-express:latest
    restart: always
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: example
      ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/

Then run docker compose -f mongo-stack.yml up -d

You can also choose fixed versions instead of latest.

Visit the official Docker page to see more configuration options.

dummyuser avatar
uy flag
you will need a volume for your database data. add `volumes: -<your_local_db_data_directory>:/data/db`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.