Customize the kernel for docker vm (to get device mapper working)

Expected behavior

I’m trying to use device mapper inside my container like so:

docker run --rm --privileged  -v /dev/:/dev/ ...

then this command should work:

dmsetup create hda --table "0 20 linear file 0"

Actual behavior

The command fails with:

/dev/mapper/control: open failed: No such device
Failure to communicate with kernel device-mapper driver.
Check that device-mapper is available in the kernel.
Command failed

even though /dev/mapper/control exists:
crw------- 1 root root 10, 236 Jun 14 12:07 /dev/mapper/control

Information

pinata output:

OS X: version 10.10.5 (build: 14F27)
Docker.app: version v1.11.1-beta13.1
Running diagnostic tests:
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160614-165318.tar.gz
Most specific failure is: No error was detected
Your unique id is: F0610334-A7A6-484A-9A21-02CD69BF06F2
Please quote this in all correspondence.

Steps to reproduce the behavior

  1. run privileged docker container with /dev:/dev volume mapping
  2. try to use dmsetup

Appears to be a duplicate of this: No device-mapper support in the kernel