首页 > 数据库 >docker 安装mongodb 并配置

docker 安装mongodb 并配置

时间:2022-11-24 16:44:27浏览次数:38  
标签:Pull mongo mongodb db mysql docker 安装 complete

1. 下载

[root@host-10-23-110-128 mysql]# docker pull mongo:latest
latest: Pulling from library/mongo
7b1a6ab2e44d: Pull complete
90eb44ebc60b: Pull complete
5085b59f2efb: Pull complete
c7499923d022: Pull complete
019496b6c44a: Pull complete
c0df4f407f69: Pull complete
351daa315b6c: Pull complete
a233e6240acc: Pull complete
a3f57d6be64f: Pull complete
dd1b5b345323: Pull complete
Digest: sha256:5be752bc5f2ac4182252d0f15d74df080923aba39700905cb26d9f70f39e9702
Status: Downloaded newer image for mongo:latest
docker.io/library/mongo:latest
[root@host-10-23-110-128 mysql]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
redis        latest    7614ae9453d1   11 months ago   113MB
mysql        latest    3218b38490ce   11 months ago   516MB
mongo        latest    dfda7a2cf273   11 months ago   693MB
[root@host-10-23-110-128 mysql]#
2. 配置

[root@host-10-23-110-128 mysql]# docker run --name mongo -p 27017:27017 -v /home/docker/data/mongo/data/:/data/db -v /home/docker/data/mongo/backup/:/data/backup -d mongo --auth
391a31a9bbe0b791c6d9ea2ae53fd431c8e38e27cbff5f528dbec67278367832
[root@host-10-23-110-128 mysql]# docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                               NAMES
391a31a9bbe0   mongo     "docker-entrypoint.s…"   4 seconds ago    Up 4 seconds    0.0.0.0:27017->27017/tcp            mongo
129f0779069d   mysql     "docker-entrypoint.s…"   24 minutes ago   Up 24 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp   mysql
a7aafa90cd99   redis     "docker-entrypoint.s…"   2 hours ago      Up 5 minutes    0.0.0.0:6379->6379/tcp              redis
[root@host-10-23-110-128 mysql]# [root@host-10-23-110-128 mysql]# docker exec -it mongo mongo admin
MongoDB shell version v5.0.5
connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("46447b1d-2681-4aae-ab77-84202a2c0d1f") }
MongoDB server version: 5.0.5
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
    https://community.mongodb.com
> db.createUser({ user: 'hett', pwd: 'hett', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });
Successfully added user: {
    "user" : "hett",
    "roles" : [
        {
            "role" : "userAdminAnyDatabase",
            "db" : "admin"
        }
    ]
}
> use admin
switched to db admin
> db.auth("hett","hett")
1
> use test01
switched to db test01
> db.createUser({user:"hett",pwd:"hett",roles:["readWrite"]});


标签:Pull,mongo,mongodb,db,mysql,docker,安装,complete
From: https://www.cnblogs.com/youran-he/p/16922344.html

相关文章

  • systemctl提示start docker.service: Unit not found. (一个伤心的故事)
    前因:很久之前做了一个项目,最近要在项目上更新,发现之前部署的K8S集群好几个节点掉线了,一顿操作下来发现这几台机器上的docker服务挂了。习惯性的喜欢用systemctl......
  • 在 Linux 7(RHEL7 和 OEL7)上安装 11.2.0.4(和 11.2.0.3)的问题
    概述REHL7和OracleLinux7在Oracle数据库11.2.0.4出来的时候还没有发布,所以安装程序确实在先决条件和安装软件时给出了一些问题。我建议首先只安装软件,因为在安......
  • Mnikube 安装 Prometheus + grafana
    官网:Prometheus,GrafanaGithub:kube-prometheusGrafana:官方单独集成K8Skube-prometheus:存储库收集Kubernetes清单、Grafana仪表板和Prometheus规则,结合文档和脚......
  • Jenkin安装及使用说明
    介绍Jenkins是基于Java开发的一种持续集成及交付工具,可用于自动打包部署项目内容下载安装官网镜像地址:https://mirrors.jenkins.io/下载地址:https://jenkins.io/......
  • linux离线安装boost
    默认安装方式https://www.boost.org,官网下载***.tar.gz离线安装包sh./bootstrap.sh安装./b2install指定安装目录方式https://www.boost.org,官网下载*......
  • php 安装 grpc 扩展
    升级gcc默认gcc的版本为4.8.5,grpc扩展需要支持c++14查询对照的话gcc6.1就可以完全至此c++14(转载至)如图:踩过的坑,重新安装升级了gcc6.5.0的版本,安装grpc还是提示如下:......
  • Docker安装及MySQL、Redis等配置
    Docker安装(CentOS版本)Docker安装文档:链接1、卸载系统之前的dockersudoyumremovedockerdocker-clientdocker-client-latestdocker-commondocker-latest\docker-......
  • docker打开2375监听端口
    1、编辑docker.service,在[service]的ExecStart,添加-Htcp://0.0.0.0:2375#vi/usr/lib/systemd/system/docker.service2、在ExecStart,添加-Htcp://0.0.0.0:2375......
  • Mac 安装GLFW
    1安装Cmake,下载GLFW源代码2通过命令行(不要用带界面的工具)--https://blog.csdn.net/pythonandjava/article/details/122777144#切换至下载解压后的GLFW源码目录cd......
  • 【Java Servlet 开发系列之一】在mac系统安装Apache Tomcat的详细步骤
    本站文章均为​​ 李华明Himi ​​​原创,转载务必在明显处注明:对于ApacheTomcat估计很多童鞋都会,那么今天就简单说下在mac上进行tomcat的安装;  第一步:下载Tomcat ......