4

I am trying to create logical volumes (like /dev/sdb or so) inside a running centos docker container. If anyone has tried doing so successfully, please help!

After installing lvm2 and running lvmetad, when I tried creating a VG, I get the below error:

bash-4.2# lvcreate -L 2G stackit

/dev/mapper/control: open failed: Operation not permitted

Failure to communicate with kernel device-mapper driver.

Check that device-mapper is available in the kernel.

striped: Required device-mapper target(s) not detected in your kernel.

Run `lvcreate --help' for more information.

enrique-carbonell
  • 5,836
  • 3
  • 30
  • 44
Raj
  • 147
  • 4
  • 15
  • 1
    Could you describe why you are trying to do this? At first glance, the question sounds like it arises from a misunderstanding of what Docker is. – sheldonh Sep 18 '14 at 08:54
  • @sheldonh I am trying to port a legacy application as a docker container. The application works on a specific partition/volume. Trying to make it available to the application from within a docker container. – Raj Sep 18 '14 at 14:42
  • Why not use the [-v command](http://docs.docker.com/reference/run/#volume-shared-filesystems) to start the container? – Howard Lee Sep 23 '14 at 17:07

1 Answers1

3

I'm not sure what exactly what you are trying to do, but docker containers by default run with restricted privileges.

Try adding (old way)

--privileged=true

Or (new way)

--cap-add=ALL

To give the container full privileges. Then you can narrow down which capabilities you actually need to give the container.

user2105103
  • 11,599
  • 2
  • 18
  • 11