I am looking to perform a simple test on my VM and see how it behaves within a container and I want to test this using libvirt and QEMU/KVM. I have a domain .xml file that runs the VM just fine on a bare metal server but I am running into issues using libvirt within the container.
My Dockerfile looks like this:
FROM ubuntu:18.04
RUN apt-get update -qy \
&& apt-get upgrade -qy \
&& apt-get install -y \
bridge-utils \
iproute2 \
python3-ipy \
socat \
qemu-kvm \
libvirt-daemon-system \
libvirt-clients \
virtinst \
bridge-utils \
iptables \
iproute2 \
dnsmasq \
vim \
&& rm -rf /var/lib/apt/lists/*
COPY *.qcow2 /
COPY *.xml /
I successfully create a simple image from this Dockerfile running sudo docker build . -t foo
and to run the container I use sudo docker run -i --privileged -t --rm foo /bin/bash
. This executes fine but once I am inserted into my containers shell, libvirt is giving me some issues. I am using a confirmed working libvirt domain XML file but when going to define it I get these errors in virsh:
error: failed to connect to the hypervisor
error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory
On a normal environment not nested or containerized it's easier to debug issues with libvirt, usually the daemon is not enabled or running, in the case of a container I am unsure of how to exactly fix the issue. When I check the status of libvirt's daemon, I get this message
System has not been booted with systemd as init system (PID 1). Can't operate.
I assume I should be passing some arguments when running the container that has to do with my network?