Hi,
I am trying to use kvm with docker as a non root user. But I am not able to change the ownership and permission to the /dev/kvm. I need to use qemu kvm through docker. I am new to docker so help me to resolve this issue.
Inside docker I have created a user and trying to give kvm group ownership to the new user, but inside docker shell if I check ownership and permission to /dev/kvm, it’s not getting changed.
I was able to change the ownership to /dev/kvm through root user. I was also able to change the root user group to kvm group. But in case of non-root user I am not able to change the ownership and permission. Because of this I am not able to use kvm virtualization through docker.
Please find my Dockerfile and start.sh:
My Dockerfile:
FROM ubuntu:16.04
LABEL maintainer "Deepak Singh deepak_sing@hcl.com
RUN apt-get update && apt-get install -y
qemu
qemu-user-static
binfmt-support
xterm
qemu-kvm
bridge-utils
cpu-checker
RUN useradd -ms /bin/bash newuser
USER newuser
WORKDIR /home/newuser
COPY ./start.sh /start.sh
ENTRYPOINT ["/start.sh"]
CMD ["/bin/bash/qemu-system-x86_64"]
"
start.sh file:
"
#!/bin/bash
set -e
set -o pipefail
gpasswd -a newuser kvm
chown newuser:kvm /dev/kvm
exec $@
"