Stanly T
Stanly T

Reputation: 1054

How to pass KVM from local machine to docker container?

I'm trying to launch Android Emulator (aka AVD) in Docker container, by next command

docker run -it img_emulator:v1 

but i get the following error:

emulator: CPU Acceleration: DISABLED
emulator: CPU Acceleration status: /dev/kvm is not found: VT disabled in BIOS or KVM kernel module not loaded
emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: /dev/kvm is not found: VT disabled in BIOS or KVM kernel module not loaded

In fact i have virtualization on my laptop with Linux 18.04. I enabled that in Bios and checked it by next command:

kvm-ok

the system reported:

INFO: /dev/kvm exists
KVM acceleration can be used

Probably i have to run my image passing there the KVM with some command something like this:

docker run -it img_emulator:v1 --device /dev/kvm

But it doesn't work. Can anybody help me please how to resolve this problem?

Upvotes: 2

Views: 12519

Answers (1)

atline
atline

Reputation: 31664

kvm is a kernel module, so it could be shared by container. Looks you put --device /dev/kvm at a wrong command place, the correct is:

docker run -idt --device /dev/kvm --name trial ubuntu:18.04

Then, copy the kvm-ok script from host to container:

docker cp /usr/sbin/kvm-ok trial:/opt

Finally, verify kvm in container:

$ docker exec -it trial /opt/kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Upvotes: 8

Related Questions