How to deploy MongoDB with Docker

preview_player
Показать описание
Jack Wallen shows you how to deploy MongoDB as a Docker container, so you can use it for your cloud-native or containerized applications.

EDITOR'S NOTE: This content was originally published March 2023 on TechRepublic. This information may be outdated depending on time of viewing.

Commands:

Pull the latest Docker image for MongoDB with the command:

docker pull mongo:latest

Create a volume for the database so we can retain data should something go awry with the container:

docker volume create mongodata

Deploy with the command:

docker run -d -v mongodata:/data/db --name mymongo --net=host mongo:latest --bind_ip 127.0.0.1 --port 27000

Access your running MongoDB container:

docker exec -it mymongo bash

Access the MongoDB console with the command:

mongosh localhost:27000

Exit the console with the exit command and then exit the container also with the exit command.
You can then return to the MongoDB console with the previous commands whenever it's time to work with the database again.

Footage courtesy of TechRepublic.

Written & Hosted by: Jack Wallen
Edited by: Justin Fraction

➤ OUR WEBSITE:

Video Editor:

#TechRepublic #TechNews #HowTo #Docker #MongoDB
Рекомендации по теме
Комментарии
Автор

You forgot the most important part, to enable the authentification! Its very dangerous!

Luca_