EvilFreelancer/docker-routeros

How to activate KVM

maxgamingir opened this issue · 1 comments

the cpu usage is too high
how to activate -enable-kvm on QEMU and config docker to access to KVM module?

Hi! In Dockerfile you may find an ENTRYPOINT directive:

ENTRYPOINT ["/routeros/entrypoint.sh"]

Content of entrypoint.sh is here.

You can write your own entrypoin.sh script and mount it with help of docker volumes, like that:

version: "3"
services:
  routeros:
    image: evilfreelancer/docker-routeros
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
      - /dev/kvm
    volumes:
      - ./entrypoin.custom.sh:/routeros/entrypoint.sh

PS. By default KVM should be activated automatically if your CPU supporting this:

CPU_FEATURES=""
KVM_OPTS=""
if [ -e /dev/kvm ]; then
   if grep -q -e vmx -e svm /proc/cpuinfo; then
      echo "Enabling KVM"
      CPU_FEATURES=",kvm=on"
      KVM_OPTS="-machine accel=kvm -enable-kvm"
   fi
fi