DEV Community

aristides villarreal
aristides villarreal

Posted on

MongoDB en Docker con docker-compose

Docker nos ofrece muchas posibilidades para el manejo de contenedores, en esta ocasión mostrare como instalarlo y utilizar una imagen de docker mediante el uso de docker-compose.
Instalar docker y docker compose


sudo apt install docker

sudo apt install docker-compose

docker-compose --version

sudo usermod -aG docker ${USER}

su - ${USER}

id -nG

sudo mkdir -p /data/db

sudo chmod 777 /data/db

sudo mkdir -p /var/log/mongodb

Enter fullscreen mode Exit fullscreen mode

Ahora cree un archivo llamado docker-compose.xml

version: '3.7'
services:
  mongodb_container:
    image: mongo:latest

    ports:
      - 27017:27017
    volumes:
      - mongodb_data_container:/data/db

volumes:
  mongodb_data_container:

Enter fullscreen mode Exit fullscreen mode

Ejecute

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Con estos pasos tenemos una imagen de MongoDB ejecutándose en Docker.

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

AWS GenAI Live!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️