MongoDB docker 容器“无法取消链接套接字文件" [英] MongoDB docker container "Failed to unlink socket file"
问题描述
我将 MongoDB 作为
主要问题是无法取消连接套接字文件/tmp/mongodb-27017.sock 不允许操作
我找到了许多解决此问题的方法,但所有解决方案都基于我使用的是 mongod 服务的想法,这不是我的情况.
我正在使用 docker 容器,并且在该容器运行之前我无法在该容器上运行命令.遗憾的是,此错误不会让容器启动并不断重新启动.
我在 3.6 版以来的 MongoDB 官方错误跟踪器上发现了问题,但它也没有任何解决方案.
我还发现了 关于 DigitalOcean 支持的类似问题,但没有找到解决方案.
警告!!创建 MogoDB 容器时,您应该始终使用
Volumes
将容器内的目录/data/db
链接到主机上.
如果 /data/db
未链接到卷,您将丢失数据.
尝试使用 docker stop
然后使用 docker rm
然后使用 docker build
或 docker-compose build
重新构建取决于您的使用情况
注意:每当您删除容器时,它的数据将随之删除.所以请确保您最近备份了数据库.
I have MongoDB as docker container When I restarted the server and tried to start the container it kept restarting forever.
I got the container log as follows
The main problem is
Failed to unlink socket file /tmp/mongodb-27017.sock Operation not permitted
I found many solutions to this problem, but all of them are based on the idea that I'm using the mongod service, which isn't my case.
I'm using a docker container and I can't run commands on this container until it is running. Sadly this error doesn't let the container start and keeps restarting.
I found the issue on the official bug tracker of MongoDB since version 3.6, but also it doesn't have any solution.
I also found a similar question on DigitalOcean support with no luck to find a solution.
Warning!! When you create a MogoDB container, You should always link the directory
/data/db
inside your container to be on the host usingVolumes
.
In case /data/db
isn't linked to a volume, you will lose your data.
Try to stop the container using docker stop <container>
then remove it completely using docker rm <container>
then re-build using docker build
or docker-compose build
depends on your usage
Note: Whenever you remove the container it's data will be removed along with it. so make sure that you have a recent backup with the database.
这篇关于MongoDB docker 容器“无法取消链接套接字文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!