How to Run Linux Docker Containers (Linux Commands) on Windows

Windows users can run Linux Docker containers thanks to Docker Desktop. Here are the steps to get started:

Install Docker Desktop for Windows :

Download and install Docker Desktop for Windows from Docker Hub. During installation, choose the Linux containers option.

Link: Docker Hub

Verify the Docker installation :

After installing Docker Desktop, run the docker version command in PowerShell to verify the installation.

Pull a Linux Docker image :

Use the docker pull command to download a Linux Docker image. For example:

  docker pull ubuntu

This will download the latest Ubuntu Linux image.

Run a Linux Docker container :

Use the docker run command to start a Linux container:

  docker run -t -d --name myubuntu ubuntu

This will run an Ubuntu container in detached mode and name it myubuntu.

Verify the container is running :

Run docker ps to see a list of running containers. You should see myubuntu in the list.

Enter the container :

Enter the container using:

  docker exec -it myubuntu bash

This will give you a bash shell inside the Ubuntu container.

Confirm the environment :

Run the cat /etc/os-release command to confirm you're running an Ubuntu Linux environment inside a container on Windows.

That's all there is to running Linux Docker containers on Windows! Docker Desktop abstracts away the OS differences and allows you to run your Linux containers unchanged. Give it a try - pull a Linux image and run a container in minutes from your Windows machine. Let me know if you have any other questions!

Come out of Shell :

type exit

Stop and Remove the container :

docker stop myubuntu
docker rm myubuntu

All Commands :

docker version
docker pull ubuntu
docker run -t -d --name myubuntu ubuntu
docker ps
docker exec -it myubuntu bash
cat /etc/os-release
exit
docker stop myubuntu
docker rm myubuntu