一. 改变容器存储位置
默认存储位置是/var/lib/docker
1.停止docker
systemctl stop docker
有时候会报错Warning: Stopping docker.service, but it can still be activated by: docker.socket
需要执行systemctl stop docker.socket
我执行的时候是先docker-compose down删掉了所有容器,下次可以试下不删容器,直接关掉docker,可能更方便
2.创建新的存储路径
mkdir -p /data/docker
3.迁移路径
rsync -avz /var/lib/docker /data/docker
4.编辑daemon.json文件
cat /etc/docker/daemon.json
{
"data-root": "/data/docker"
}
5.载入配置文件并启动
systemctl daemon-reload && systemctl restart docker
二. 启动mongo失败
docker镜像存储位置改变后,启动mongo失败,报错Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
解决方法:使用docker inspect 容器名,找到下面信息
cd /data/docker/overlay2/1f62bf8c5c479319b86b31cb81763279655144420572c2600af4be684ecfe9ab
cd diff/tmp && rm mongodb-27017.sock
然后重启mongo即可
参考:https://www.cnblogs.com/innocenter/p/17084776.html
标签:容器,mongo,Failed,报错,docker,data,socket From: https://www.cnblogs.com/regit/p/17191156.html