Common commands for deploying influxdb and Mongo using docker

Time:2019-10-16

Database deployment based on docker

sudo docker pull influxdb
sudo docker pull mongo
sudo docker run -p 27017:27017 -v xxx:/xxx–name xxxx -d mongo:latest
sudo docker run -d -p8086:8086 –name xxx influxdb:latest

Initialize mongodb database

Enter Mongo image configuration user password


mongo 127.0.0.1
use admin;
db.createUser({user: "xxx", pwd: "xxx", roles: [{ role: "root", db: "admin" }]});
db.getUser("xxx")

Import data

Enter Mongo container:

mongoimport -d aaa -c xxx.json

Check import results:


mongo 127.0.0.1
show databases;
use aaa;
db.xxx.find();

Create BBB database


use bbb
db
db.keynes_record.insert({"name":"test"})
show databases;

Initialize influxdb

Enter the docker container:


influx
CREATE DATABASE keynes
SHOW DATABASES

summary

The above is a common command that Xiaobian introduced to you to deploy influxdb and Mongo using docker. I hope it can help you. If you have any questions, please leave me a message, and Xiaobian will reply you in time!