在OS X上更改Docker的存储驱动程序 [英] Change storage driver for Docker on OS X

查看:124
本文介绍了在OS X上更改Docker的存储驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这基本上是后续这个问题,但现在由于OS X Docker不再需要Docker Toolbox(即不再需要VirtualBox),所以我完全失去了如何从 AUFS 切换到 devicemapper 或其他东西。



我在这里面临的问题是 AUFS 中缺少的hardlink支持,这在安装过程中会出现问题的Android SDK,所以我希望 devicemapper 将帮助我在这里。



那么,我如何更改存储Docker在OS X中的本机实现的驱动程序?

解决方案

Docker for Mac运行的Alpine Linux VM不支持 devicemapper 驱动程序,但它可以运行 overlay2 驱动程序。



没有用于管理此配置的UI 适用于Mac UI的Docker已更新为包含守护进程部分,您可以在其中编辑 docker.json 配置文件。



获得Docker图标>首选项>守护进程>高级并将存储驱动程序设置为 overlay2

  {storage-driver:overlay2} 

kojiros 全面分步回答详情。



手动配置编辑



可以在〜/ Library / Containers / com.docker.docker / Data / database 中修改mac上的Docker config 文件。



此目录是一个git repo,通常为空白:

  $ cd〜/ Library / Containers / com.docker.docker / Data / database 
$ ls -al
total 0
drwxr-xr-x 4用户工作人员136 28 Sep 02: 46。
drwxr-xr-x 20用户工作人员680 28 Sep 02:54 ..
drwxr-xr-x 11用户工作人员374 28 Sep 02:58 .git

git数据库中有文件

 在分支主机上
更改不是为了提交执行:
(使用git add / rm< file> ...来更新将被提交的内容)
(使用git checkout - < file> ...放弃工作目录中的更改)

已删除:com.docker.driver.amd64-linux / etc / docker / daemon.json
已删除:com.docker.driver.amd64-linux / etc / hostname
已删除:com.docker.driver.amd64-linux / etc / sysctl.conf
.... $ b要从git中检索以前的内容,请运行:

$ b $ / pre>

  $ git reset --hard HEAD 

编辑docker守护进程配置文件现在存在,以包含 overlay2 存储驱动程序。

  $ vi com.docker.driver.amd64-linux / etc / docker / daemon.json 

VM上的Docker将需要大部分 / var / lib / docker 然后才能开始使用新的存储驱动程序。这将使您的所有容器,图像和卷都删除!备份你需要的任何事情。



使用屏幕附加到虚拟机的tty brew install screen 如果你没有它)

  $ screen〜/ Library / Containers / com.docker.docker / Data / com.docker.driver.amd64-linux / tty 

使用 root登录,无密码

  moby:〜#/etc/init.d/docker stop 
moby:〜#rm -rf / var / lib / docker / *

使用 ctrl - d



使用 ctrl退出屏幕会话 - < kbd>然后 d



现在你可以在mac上提交你的更改

  $ git commit -m overlay com.docker.driver.amd64-linux / etc / porter / daemon.json 

Docker将在提交时自动获取更改,VM将重新启动。



您现在有一个适用于Mac VM的Docker,可以使用 overlay2 存储驱动程序。如果这不能解决你的问题,有一些工作,你可能可以弄清楚如何获得在虚拟机中工作的 devicemapper 支持。一旦你知道这一切都是一样的。



注意升级到Docker for Mac可能会引起一些奇怪。最后升级我的所有容器/图像从 docker ps docker图像中消失。我不得不重新设置git存储库并重新启动Docker以使配置更改返回,然后所有的数据都回来了。


This is basically a follow-up to this question, but now since the OS X Docker no longer needs Docker Toolbox (i.e. no longer needs VirtualBox), I'm totally lost how to switch from AUFS to devicemapper or something else.

The issue I'm facing here as well is the missing hardlink support in AUFS which makes problems during the installation of the Android SDK, so I hope devicemapper will help me here.

So, how can I change the storage driver of Docker's native implementation in OS X?

解决方案

The Alpine Linux VM that Docker for Mac runs doesn't support the devicemapper driver but it can run the overlay2 driver.

There's no UI for managing this config yet The Docker for Mac UI has been updated to include a "Daemon" section where you can edit the docker.json config file.

Got to the Docker icon > "Preferences" > "Daemon" > "Advanced" and set the storage-driver to overlay2

{ "storage-driver": "overlay2" }

See kojiros answer for full step by step details.

Manual Config Editing

You can modify the Docker config files on your mac in ~/Library/Containers/com.docker.docker/Data/database.

This directory is a git repo and it will normally be blank:

$ cd ~/Library/Containers/com.docker.docker/Data/database
$ ls -al
total 0
drwxr-xr-x   4 user  staff  136 28 Sep 02:46 .
drwxr-xr-x  20 user  staff  680 28 Sep 02:54 ..
drwxr-xr-x  11 user  staff  374 28 Sep 02:58 .git

There are files in the git database though

$ git status
On branch master
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    deleted:    com.docker.driver.amd64-linux/etc/docker/daemon.json
    deleted:    com.docker.driver.amd64-linux/etc/hostname
    deleted:    com.docker.driver.amd64-linux/etc/sysctl.conf
....

To retrieve the previous contents from git, run:

$ git reset --hard HEAD

Edit the docker daemon config file that now exists, to include the overlay2 storage driver.

$ vi com.docker.driver.amd64-linux/etc/docker/daemon.json

Docker on the VM will need most of /var/lib/docker removed before you can start with a new storage driver. This will DELETE all of your containers, images and volumes! Take backups of anything you need beforehand.

Attach to the VM's tty with screen (brew install screen if you don't have it)

$ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

Login with root, no password

moby:~# /etc/init.d/docker stop
moby:~# rm -rf /var/lib/docker/*

Exit the prompt with ctrl-d

Exit the screen session with ctrl-a then d

Now you can commit your changes back on the mac

$ git commit -m overlay com.docker.driver.amd64-linux/etc/docker/daemon.json

Changes will be picked up automatically by Docker on commit and the VM will be restarted.

You now have a Docker for Mac VM running with the overlay2 storage driver. If that doesn't resolve your problems, with some work you could probably figure out how to get devicemapper support working in the VM too. The steps once you've figured that out are all the same.

Note Upgrades to Docker for Mac can cause some weirdness. Last upgrade all my containers/images disappeared from a docker ps or docker images. I had to reset the git repository again and restart Docker for my config changes to come back, then all the data came back.

这篇关于在OS X上更改Docker的存储驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆