我如何将Docker存储驱动程序更改为mac上的devicemapper

问题描述:

我试图将存储驱动程序更改为mac上的devicemapper。并按照Change docker storage driver on Mac OS X我如何将Docker存储驱动程序更改为mac上的devicemapper

中的步骤,但我得到了以下错误,我的docker for mac是最新版本。

$ docker-machine create --driver virtualbox --engine-storage-driver devicemapper test2 
Running pre-create checks... 
Creating machine... 
(test2) Copying /Users/weiwang/.docker/machine/cache/boot2docker.iso to /Users/weiwang/.docker/machine/machines/test2/boot2docker.iso... 
(test2) Creating VirtualBox VM... 
(test2) Creating SSH key... 
(test2) Starting the VM... 
(test2) Check network to re-create if needed... 
(test2) Waiting for an IP... 
Waiting for machine to be running, this may take a few minutes... 
Detecting operating system of created instance... 
Waiting for SSH to be available... 
Detecting the provisioner... 
Provisioning with boot2docker... 
Copying certs to the local machine directory... 
Copying certs to the remote machine... 
Setting Docker configuration on the remote daemon... 
Checking connection to Docker... 
Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.105:2376": read tcp 192.168.99.1:49168->192.168.99.105:2376: read: connection reset by peer 
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. 
Be advised that this will trigger a Docker daemon restart which will stop running containers. 

注意:请阅读更新

Devicemapper不再被支持。 你可以使用叠加也很不错。

用法: docker-machine create --driver virtualbox --engine-storage-driver overlay test2

编辑:

我最初的评论没有正确地回答这个问题。在对devicemapper存储驱动程序的工作方式进行了一些更深入的研究之后,事实证明,基本操作系统docker-machine使用的默认boot2docker不支持devicemapper存储驱动程序。

下面是支持的发行版的列表:

  • RHEL/CentOS的/ Fedora的
  • 的Ubuntu 12.04
  • 的Ubuntu 14.04
  • Debian的

更详细的信息可以发现here

所以要解决这个问题,你需要在虚拟机中安装一个提到的发行版。添加一个SSH服务器和一个无密码sudo用户,可以在不使用tty的情况下运行命令。

我在VirtualBox中安装了一个CentOS虚拟机,添加了一个NAT和一个仅限主机的驱动程序(用于下载Internet包的NAT,以及用于专用网络的docker-machine和VM的Host only适配器可以通信。)

设置VM后,可以使用以下命令将其连接到docker-machine。 docker-machine会挂载到VM并检查是否安装了Docker Engine。如果情况并非如此,它将自动下载并配置。在这里使用的通用驱动程序

docker-machine create \ 
    --driver generic \ 
    --generic-ip-address=192.168.58.14 \ 
    --generic-ssh-port 22 \ 
    --generic-ssh-key ~/.ssh/id_rsa \ 
    --engine-storage-driver devicemapper \ 
    docker-centos 

更多信息: https://docs.docker.com/machine/drivers/generic/

希望这可以帮助你多一点就比最初的答案:)

+0

感谢Menzo的方式,我能够创造机器与覆盖作为存储驱动器,但这并不能解决我的问题。我需要在容器内部运行服务,但该服务不支持aufs和覆盖 – weiwang

+0

@weiwang我对这个主题做了更多的研究并更新了我的答案。它肯定仍然可以使用devicemapper存储驱动程序。 Docker只是不支持它的默认基本操作系统。 –

+0

太棒了!谢谢(你的)信息。 – weiwang