Skip to content

A simple Bash-based solution for switching between Docker Desktop and VirtualBox on Linux by enabling or disabling KVM, ensuring conflict-free hardware virtualization.

License

Notifications You must be signed in to change notification settings

hehealexandru/docker_virualbox_switch_scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”€ Docker Desktop ↔ VirtualBox Hypervisor Switch (Linux)

Linux Ubuntu Docker VirtualBox KVM Shell


πŸ“Œ Overview

This project provides two simple Bash scripts that allow you to safely switch between:

  • Docker Desktop for Linux (which requires KVM)
  • VirtualBox (which requires direct VT-x access)

On Linux, these two cannot run at the same time because they both need exclusive control of the hardware virtualization engine.

This solution allows both tools to coexist on the same system using a clean switch + reboot approach.


🧠 Technical Background

  • Docker Desktop for Linux runs inside a lightweight VM using QEMU + KVM
  • VirtualBox requires direct access to Intel VT-x / AMD-V
  • Only one hypervisor can control hardware virtualization at a time

Attempting to run both simultaneously results in errors such as:

  • VT-x is being used by another hypervisor
  • /dev/kvm not found

πŸ”€ Switching Concept

Mode KVM VirtualBox Docker Desktop
Docker Mode Enabled ❌ βœ…
VirtualBox Mode Disabled βœ… ❌

A reboot is required after each switch to ensure stability.


βš™οΈ Installation Tutorial:

Clone the repository:

git clone https://github.com/hehealexandru/docker_virualbox_switch_scripts.git
cd docker_virualbox_switch_scripts

Move the Scripts to System Path

sudo mv use-docker use-virtualbox /usr/local/bin/

Make the Scripts Executable

sudo chmod +x /usr/local/bin/use-docker
sudo chmod +x /usr/local/bin/use-virtualbox

Verify Installation

which use-docker
which use-virtualbox

Run which Program You want to Use

use-docker

Or

use-virtualbox

🚧 Future Work

This project is currently tested on Ubuntu 22.04 / 24.04.

Future improvements will focus on extending compatibility to other Linux distributions, including:

  • Fedora
  • Arch Linux
  • Independent OS

Distribution-specific differences (package names, systemd behavior, kernel module handling) will be addressed as part of this effort.

About

A simple Bash-based solution for switching between Docker Desktop and VirtualBox on Linux by enabling or disabling KVM, ensuring conflict-free hardware virtualization.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages