简体   繁体   English

在 Mac OS 上更改 Docker 根目录

[英]Change Docker Root Dir on Mac OS

There is already a question on Stack Overflow about this but the accepted answer doesn't work anymore. Stack Overflow 上已经有一个关于此的问题,但接受的答案不再起作用。

My Docker Desktop app is using the directory below:我的 Docker 桌面应用程序正在使用以下目录:

/Users/guilpejon/Library/Containers/com.docker.docker/Data/vms/0/data

And docker info gives me this: docker info给了我这个:

Docker Root Dir: /mnt/sda1/var/lib/docker

The question is, how do I change the Docker Root Dir to use the same directory used by the Docker Desktop app?问题是,如何更改Docker Root Dir以使用 Docker 桌面应用程序使用的相同目录?

With docker command you can use --data-root option to provide path of root directory.使用 docker 命令,您可以使用 --data-root 选项提供根目录的路径。

Also in docker Preference > Docker Engine option you can provide configuration for docker demon in JSON config.同样在 docker Preference > Docker Engine 选项中,您可以在 Z0ECD11C1D7A2874201D84D 中为 docker 恶魔提供配置。 You need to copy content from existing root directory to new directory.您需要将内容从现有根目录复制到新目录。

For more option refer https://docs.docker.com/engine/reference/commandline/dockerd/有关更多选项,请参阅https://docs.docker.com/engine/reference/commandline/dockerd/

I tried to follow Nilesh's answer but Docker Desktop gave me an error while trying to do this:我试图遵循 Nilesh 的回答,但 Docker Desktop 在尝试执行此操作时给了我一个错误:

{
  "features": {
    "buildkit": true
  },
  "experimental": false,
  "data-root": "/Users/guilpejon/Library/Containers/com.docker.docker/Data/vms/0/data"
}

On the error pop up window, I chose to reset docker to factory settings and then the Docker Root Dir changed to /var/lib/docker , which works for me.在弹出错误 window 时,我选择将 docker 重置为出厂设置,然后将 Docker 根目录更改为/var/lib/docker ,这对我有用。

Now I can control docker's resources through Docker Desktop app again, which is what I wanted.现在我又可以通过 Docker Desktop app 来控制 docker 的资源了,这正是我想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM