Implementation code for using mongodb database in Docker

Implementation code for using mongodb database in Docker

Get the mongo image

sudo docker pull mongo

Run the mongodb service

sudo docker run -p 27017:27017 -v /tmp/db:/data/db -d mongo

Run the mongodb client

sudo docker run -it mongo mongo --host <host IP address> --port 27017
> show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
> use local
switched to db local
> show collections
startup_log
> db.startup_log.find()
...

Use mongo-express to manage mongodb

mongo-express is a visual graphical management tool for MongoDB. Here we still run a mongo-express through docker to manage the mongodb service created above.

Download the mongo-express image

sudo docker pull docker.io/mongo-express

Start the mongo-express service

sudo docker run -it --rm -p 8081:8081 --link <mongoDB container ID>:mongo mongo-express

Access mongo-express

Access through a browser

http://<host machine IP address>:8081

Use mongoclient to manage mongodb

Download the mongoclient image

sudo docker pull mongoclient/mongoclient

Start the mongoclient service

Copy the code as follows:
sudo docker run --name mongoclient -d -p 3000:3000 -e MONGO_URL=mongodb://<host machine IP address>:27017/ mongoclient/mongoclient

Access mongoclient

Access through a browser

http://<host IP address>:3000

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to install the latest version of MongoDB using Docker
  • Docker container deployment attempt - multi-container communication (node+mongoDB+nginx)
  • Detailed explanation of using mongodb database in docker (access in LAN)
  • Method for implementing authorized access to MongoDB based on Docker
  • Detailed explanation of how to install mongodb using docker on linux

<<:  Commonplace talk about MySQL event scheduler (must read)

>>:  How to use webpack and rollup to package component libraries

Recommend

Detailed description of ffmpeg Chinese parameters

FFMPEG 3.4.1 version parameter details Usage: ffm...

Web Design Tutorial (2): On Imitation and Plagiarism

<br />In the previous article, I introduced ...

Comparative Analysis of MySQL Binlog Log Processing Tools

Table of contents Canal Maxwell Databus Alibaba C...

HTML small tag usage tips

Phrase elements such as <em></em> can ...

Basic reference types of JavaScript advanced programming

Table of contents 1. Date 2. RegExp 3. Original p...

Vue+element implements drop-down menu with local search function example

need: The backend returns an array object, which ...

Vue's global watermark implementation example

Table of contents 1. Create a watermark Js file 2...

Summary of the pitfalls of using primary keys and rowids in MySQL

Preface We may have heard of the concept of rowid...

Four methods of using JS to determine data types

Table of contents Preface 1. typeof 2. instanceof...

How to set focus on HTML elements

Copy code The code is as follows: <body <fo...

User-centered design

I've been asked a lot lately about an apparen...

Sample code for a simple seamless scrolling carousel implemented with native Js

There are many loopholes in the simple seamless s...

How to implement Nginx configuration detection service status

1. Check whether the check status module is insta...

Two ways to completely delete users under Linux

Linux Operation Experimental environment: Centos7...

Detailed explanation of Vue3.0 + TypeScript + Vite first experience

Table of contents Project Creation Project Struct...