Docker Community Forums

Share and learn in the Docker community.

Problem running ubuntu/qemu-kvm and libvirt in docker

I am trying to run a container on an x86 host with host os ubuntu.
I am unable to run virsh commands in this container. Here are the details:
I had started the container with ‘docker run -t -i --privileged --name xxx yyy’

Ubuntu QEMU/KVM

FROM ubuntu:14.04

Install QEMU/KVM

RUN cd .
&& sudo apt-get update
&& sudo apt-get install -y qemu
&& sudo apt-get install -y qemu-kvm
&& sudo apt-get install -y libvirt-bin
&& sudo apt-get clean

root@c6508adee30a:/var/run# virsh list
error: failed to connect to the hypervisor
error: no valid connection
error: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock’: No such file or directory

root@c6508adee30a:/var/run# libvirtd -d
libvirtd: error while loading shared libraries: libvirt-lxc.so.0: cannot open shared object file: Permission denied

root@c6508adee30a:/# id -a
uid=0(root) gid=0(root) groups=0(root),107(libvirtd)
root@c6508adee30a:/#

root@c6508adee30a:/# id -un
root

root@c6508adee30a:/# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

root@c6508adee30a:/# sudo libvirtd -d
libvirtd: error while loading shared libraries: libvirt-lxc.so.0: cannot open shared object file: Permission denied
root@c6508adee30a:/#
root@c6508adee30a:/# which libvirtd
/usr/sbin/libvirtd