Docker pull MONGO (pulls image default latest version)
Docker images (view image)
Docker run-p 27017:27017-td MONGO (boot mirror)
Docker PS (view boot image)
Docker exec-it Mirror Id/bin/bash (Enter container)
MONGO (enter MongoDB)
Here are the steps to create an administrative account user and a regular user after the installation is complete,
Create an administrative account, and then exit.
Use admin
Db.createuser (
{
User: "Admin",
PWD: "Password",
Roles: [{role: ' Root ', db: ' admin '}]
}
);
Exit (Exit Container)
MONGO--port 27017-u admin-p Password--authenticationdatabase admin (create test user with the newly created user login database)
Use test
Db.createuser (
{
User: "Tester",
PWD: "Password",
Roles: [
{role: "ReadWrite", DB: "Test"}
]
}
);
Exit
Mongo-u tester-p--authenticationdatabase Test (login with the test user just created)
MongoDB Other Operations Command
Show DBS (Display database)
Use dbname (switch to database)
Show collections (Show Table)
Db.find. Table name (view table data)
Docker installs MongoDB and sets up users