How to run Linux libraries on Docker on Windows?


Here in this article, we will learn about Linux libraries. What is the actual function of these libraries and what are the different types of libraries. Then we will understand to use these Linux libraries on the Windows OS with the help of various methods mentioned below.

What are the Linux libraries?

The Linux terminal works and follows only the commands. It is a “Text Only Console”, that responds to terminal commands. The definitions or the code for these commands or functions are stored in libraries.

Types of Linux libraries

The libraries can be divided based on the nature of the executable.

  • Static library

  • Dynamic library

Static Library − The command and its definitions are enclosed in an executable.

Dynamic Library − The command and its definitions are not bound in the executable. The definition of the command is not present in the executable only the command is present.


There are various methods or ways to use Linux libraries on a Windows host. Some of them are listed below.

  • Using Docker Desktop on Windows Host.

  • Using Virtual Machine on Windows Host.

  • Using WSL (Windows Subsystem for Linux) on Windows Host.

Here we will implement the execution for various Linux libraries and packages.

Docker Desktop

It is a desktop application for Windows to run Docker containers on the Windows platform. It is available for Apple, Linux, and Windows.

Step 1 − Open the Docker Desktop application

There are two ways we can create, run, stop, destroy, and manage containers. One is using this “desktop version” or we can use the “windows terminal”. Here we will demo using the windows terminal.

Step 2 − Open the terminal from start. If not installed, use the Microsoft store to install “windows terminal”. Check the docker version using the command “docker --version”.


$docker --version


Docker version 20.10.17, build 100c701

Step 3 − Run the Ubuntu container and commands

Now run an Ubuntu image inside a docker container. And, get inside this container to execute the Linux commands

PS C:\Users\HP> docker run -itd --name cont1 ubuntu
PS C:\Users\HP> docker ps
36a15a62f09a    ubuntu     "bash"   7 seconds ago  Up 4 seconds           cont1
PS C:\Users\HP> docker exec -it cont1 bash
root@36a15a62f09a:/# pwd
root@36a15a62f09a:/# whoami
root@36a15a62f09a:/# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@36a15a62f09a:/# which ls

Hence we were able to run the Linux libraries on Docker on Windows.

Virtual Machine

Instead of using the Docker Desktop, we can use the virtual machine to install a Linux distro and then run the Docker container on it. Install a Virtualisation tool, we are going to use the Oracle VM VirtualBox Manager. Create a Virtual Machine of Ubuntu and start it.

Step 1 − Start the Ubuntu VM

After the VM starts, it will open a new display window for the Ubuntu VM.

Step 2 − Open the Linux terminal and run a docker Container.

hemant@hemant-VirtualBox:~$ docker run -itd --name busybox_cont busybox
hemant@hemant-VirtualBox:~$ docker ps
5836441ac4de busybox "sh" 5 seconds ago Up 3 seconds

Step 3 − Execute the Linux commands here.

hemant@hemant-VirtualBox:~$ docker exec -it busybox_cont sh / # ls bin dev etc home proc root sys tmp usr var / # pwd / / # date Thu Dec 8 04:45:16 UTC 2022 / # which date /bin/date

WSL: Windows Subsystem for Linux

WSL is a product of Microsoft. This is a Linux Kernel that works seamlessly on the Microsoft architecture.

Step 1 − Install it from the Microsoft Store

Search WSL on the Microsoft Store, download, and install it.

Install Ubuntu on the WSL using the below command on PowerShell.

$ wsl --install -d ubuntu

Now you can launch the application from the start menu by searching “Ubuntu”.

Step 2 − We have WSL for Ubuntu Installed. Now run the Linux library commands.

hemant@DESKTOP-G29Q9GU:~$ pwd
hemant@DESKTOP-G29Q9GU:~$ date
Thu Dec 8 10:34:53 IST 2022
hemant@DESKTOP-G29Q9GU:~$ which date

hemant@DESKTOP-G29Q9GU:~$ which ls

hemant@DESKTOP-G29Q9GU:~$ whatis ls
ls (1) - list directory contents
hemant@DESKTOP-G29Q9GU:~$ whatis date
date (1) - print or set the system date and time
hemant@DESKTOP-G29Q9GU:~$ whatis wget
wget (1) - The non-interactive network downloader.


Hence in this article, we were able to execute the Linux library commands on the Windows system using various methods like WSL, VM, and Docker Desktop.