Change the driver for Docker on OS X

This is basically the next one for this question , but now, since OS X Docker no longer needs the Docker Toolbox (that is, VirtualBox is no longer required) m completely lost how to switch from AUFS to devicemapper or something else.

The problem I encountered here is the lack of support for hard drives in AUFS , which creates problems when installing the Android SDK, so I hope devicemapper helps me here.

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

+6
source share
3 answers

The Alpine Linux virtual machine supported by Docker for Mac does not support the devicemapper driver, but can run the overlay2 driver.

There is no interface to manage this configuration. The Docker interface for Mac has been updated. It includes a "Daemon" section in which you can edit the docker.json configuration file.

Get the Docker icon> "Settings"> "Daemon"> "Advanced" and set the storage-driver parameter to overlay2

 { "storage-driver": "overlay2" } 

See kojiros for full details.

Editing Manual Settings

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

This directory is a git repository, and it will usually be empty:

 $ 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, but

 $ 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 get the previous contents from git, run:

 $ git reset --hard HEAD 

Edit the overlay2 daemon configuration file that now exists to enable the overlay2 storage overlay2 .

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

A docker in a virtual machine will need most of /var/lib/docker before you can start with the new storage driver. This is DELETING all your containers, images and volumes! Back up everything you need in advance.

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

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

Log in as root , no password

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

Exit the prompt using ctrl - d

Exit the screen session using ctrl - a , then d

Now you can transfer your changes to mac

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

Changes will be automatically activated by Docker when committed, and the virtual machine will restart.

You now have Docker for Mac VM with the overlay2 storage overlay2 . If this does not solve your problems, with some work you can probably figure out how to get devicemapper support working in VM. Steps, as soon as you understand it, anyway.

Note Upgrading to Docker for Mac may cause some oddities. The last update of all my containers / images disappeared from docker ps or docker images . I again had to reset the git repository and restart Docker for my configuration changes to return, and then all the data returned.

+13
source

Matt is right that the Docker kernel for Mac does not support devicemapper by default, but overall there is a better way to change daemon options:

Launch Docker for Mac. Click whale in the menu bar, then click "Settings"

docker whale menu with highlighted preference option

Click Daemon Icon in Docker Settings for Mac

Click Advanced and provide JSON to configure your daemon.

Docker Settings Dialog in the Daemon / Advanced Section

Then click "Apply" and "Restart" and check the change:

 $ docker info | grep Stor Storage Driver: overlay2 
+5
source

Even when using docker-for-mac, you still have OSX virtualization using hyperkit / xhyve , since the Darwin kernel still does not start docker “natively”. Thus, you cannot select the storage driver as you actually expect. Also read the last bulletin item here https://docs.docker.com/docker-for-mac/docker-toolbox/#/the-docker-for-mac-environment

During installation, Docker for Mac provides HyperKit VMs based on Alpine Linux running on the Docker Engine. It provides a docker in socket API in the directory /var/tmp/docker.sock

In docker-for-mac, OSXFS is used to exchange your local OSX folders with xhyve slim vm , so linux kernel / os (alpine) selects them when the containers start and binds any volumes to the 'vms system' file, which is then synchronized.

AFAIK there is no way to select the storage driver in docker-for-mac, since this is not possible because OSXFS synchronizes with the host with alpine-vm, which then offers this to the containers.

+1
source

All Articles