docker部署MongoDB

1、首先拉取镜像

$ docker pull mongo

采用上述命令拉取镜像,

2、运行容器

docker run --name mongodb -p 27017:27017 -d mong

采用命令运行容器,但是运行完了之后会发现容器闪退了,docker logs 容器id查看了一下,

{"t":{"$date":"2023-05-25T10:46:13.173+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-05-25T10:46:13.173+00:00"},"s":"I",  "c":"NETWORK",  "id":4915701, "ctx":"main","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-05-25T10:46:13.174+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2023-05-25T10:46:13.175+00:00"},"s":"I",  "c":"REPL",     "id":5123008,

发现是这么一堆看不懂,但是隐隐约约可以看到一些error,copy出来之后大概是如下

{
	"t": {
		"$date": "2023-05-25T10:46:13.186+00:00"
	},
	"s": "F",
	"c": "CONTROL",
	"id": 6384300,
	"ctx": "main",
	"msg": "Writing fatal message",
	"attr": {
		"message": "std::exception::what(): Operation not permitted\nActual exception type: std::system_error\n\n"
	}
}



查看一下message,发现是通常是由于Docker容器内的权限问题导致的。

解决办法,加上参数--privileged就OK了,所以修改命令

docker run --privileged --name mongodb -p 27017:27017 -d mong

成功运行

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值