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

Two common solutions to html text overflow display ellipsis characters

Method 1: Use CSS overflow omission to solve The ...

How to implement scheduled backup of CentOS MySQL database

The following script is used for scheduled backup...

How to manually encapsulate paging components in Vue3.0

This article shares the specific code of the vue3...

How to preview pdf file using pdfjs in vue

Table of contents Preface think Library directory...

Detailed explanation of how to pass password to ssh/scp command in bash script

Install SSHPASS For most recent operating systems...

Form submission page refresh does not jump

1. Design source code Copy code The code is as fol...

MySQL 5.7.17 installation and configuration method graphic tutorial (windows10)

MySQL 5.7.17 installation and configuration metho...

Vue+webrtc (Tencent Cloud) practice of implementing live broadcast function

Table of contents 1. Live broadcast effect 2. Ste...

Detailed explanation of the use of docker tag and docker push

Docker tag detailed explanation The use of the do...

Detailed explanation of Bootstrap grid vertical and horizontal alignment

Table of contents 1. Bootstrap Grid Layout 2. Ver...

Detailed explanation of Docker container network port configuration process

Exposing network ports In fact, there are two par...

CentOS 7 method to modify the gateway and configure the IP example

When installing the centos7 version, choose to co...