mongosh

rtsp/mongosh Docker 镜像

基于Debian的Docker镜像,预装MongoDB Shell(mongosh)

3 次收藏下载次数: 0状态:社区镜像维护者:rtsp仓库类型:镜像最近更新:
下载命令
点击查看

RTSP MongoDB Shell Docker镜像

基于Debian系统,预装https://docs.mongodb.com/mongodb-shell/的Docker镜像。

mongosh使用说明

关于mongosh命令的使用方法,请参考以下文档:

  • https://docs.mongodb.com/mongodb-shell/connect/
  • https://docs.mongodb.com/mongodb-shell/run-commands/
    • https://docs.mongodb.com/mongodb-shell/crud/
    • https://docs.mongodb.com/mongodb-shell/run-agg-pipelines/
  • https://docs.mongodb.com/mongodb-shell/reference/options/

使用方法

若要使用GitHub Container Registry而非Docker Hub中的镜像,可将以下说明中的rtsp/mongosh替换为ghcr.io/rtsp/docker-mongosh。

拉取镜像

ShellSession
docker pull docker.xuanyuan.run/rtsp/mongosh

交互模式

通过以下命令以交互模式运行mongosh并连接到MongoDB:

ShellSession
docker run --rm -it docker.xuanyuan.run/rtsp/mongosh mongosh -- mongodb://172.17.0.1:27017

通过以下命令以交互模式进入容器的bash终端:

ShellSession
docker run --rm -it docker.xuanyuan.run/rtsp/mongosh bash

运行特定命令

通过以下命令运行特定的mongosh命令(如执行eval表达式):

ShellSession
docker run --rm docker.xuanyuan.run/rtsp/mongosh mongosh -- mongodb://172.17.0.1:27017 --eval 'db.serverStatus()'

以守护进程模式运行

首先启动守护进程容器:

ShellSession
docker run -d --name mongosh docker.xuanyuan.run/rtsp/mongosh

然后通过docker exec执行命令或进入交互模式:

ShellSession
# 执行特定命令
docker exec mongosh mongosh -- mongodb://172.17.0.1:27017 --eval 'db.serverStatus()'

# 进入mongosh交互模式
docker exec -it mongosh mongosh -- mongodb://172.17.0.1:27017

# 进入bash终端
docker exec -it mongosh bash

以Kubernetes Pod运行

创建Pod配置文件(如mongosh-pod.yaml):

yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: mongosh
spec:
  containers:
  - name: mongosh
    image: docker.xuanyuan.run/rtsp/mongosh:latest

通过kubectl执行命令或进入交互模式:

ShellSession
# 执行特定命令
kubectl exec mongosh -- mongosh mongodb://ENDPOINT:27017 --eval 'db.serverStatus()'

# 进入mongosh交互模式
kubectl exec -it mongosh -- mongosh mongodb://ENDPOINT:27017

# 进入bash终端
kubectl exec -it mongosh -- bash

以Kubernetes Deployment运行

创建Deployment配置文件(如mongosh-deployment.yaml):

yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongosh
spec:
  replicas: 1
  selector:
    matchLabels:
      name: mongosh
  template:
    metadata:
      labels:
        name: mongosh
    spec:
      containers:
        - name: mongosh
          image: docker.xuanyuan.run/rtsp/mongosh:latest
          imagePullPolicy: Always

通过kubectl执行命令或进入交互模式:

ShellSession
# 执行特定命令
kubectl exec deployment/mongosh -- mongosh mongodb://ENDPOINT:27017 --eval 'db.serverStatus()'

# 进入mongosh交互模式
kubectl exec -it deployment/mongosh -- mongosh mongodb://ENDPOINT:27017

# 进入bash终端
kubectl exec -it deployment/mongosh -- bash

相关链接

镜像资源

  • Docker Hub:https://hub.docker.com/r/rtsp/mongosh/
  • GitHub容器 registry:https://github.com/rtsp/docker-mongosh/pkgs/container/docker-mongosh

源代码

  • https://github.com/rtsp/docker-mongosh

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 mongosh 镜像标签

docker pull docker.xuanyuan.run/rtsp/mongosh:<标签>

DockerHub 原生拉取命令

docker pull rtsp/mongosh:<标签>
专业版 · 高速稳定拉取镜像
50GB 仅 ¥8/年
高速镜像下载在线技术支持专业版保障服务可用付费会员免广告