Install Docker On Wsl2 Without Docker Desktop

Install Docker On Wsl2 Without Docker Desktop

If you're working with Windows Subsystem for Linux 2 (WSL2) and want to install Docker without using Docker Desktop, you've come to the right place. This guide will walk you through the steps to install Docker on WSL2 without the need for Docker Desktop.


Before we dive into the installation process, let's make sure you have the necessary prerequisites:

  • Windows 10 with WSL2 enabled
  • A Linux distribution installed on WSL2 (such as Ubuntu)

Now, let's get started with the installation steps.

Step 1: Update Packages

The first step is to update the packages on your WSL2 Linux distribution. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

This will ensure that your system has the latest package information and updates.

Step 2: Install Docker Dependencies

Next, we need to install the required dependencies for Docker to function properly. Run the following command:

sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

Step 3: Add Docker Repository

To download and install Docker, we need to add the Docker repository to the package manager source list. Run the following commands:

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 4: Install Docker Engine

Now that the repository has been added, we can proceed to install Docker Engine. Run the following command:

sudo apt update
sudo apt install -y docker-ce docker-ce-cli

Step 5: Add User to Docker Group

By default, only the root user can run Docker commands. To allow your user to use Docker without using sudo, add your user to the docker group. Run the following command:

sudo usermod -aG docker $USER

Step 6: Test Docker Installation

To verify that Docker has been installed correctly, run the following command:

docker run hello-world

If everything is set up properly, you should see a "Hello from Docker!" message.

Congratulations! You have successfully installed Docker on WSL2 without Docker Desktop.

Now you can start using Docker from your WSL2 Linux distribution. Docker provides a powerful and efficient way to package and distribute applications, making it easier to deploy them across different environments.

To further enhance your Docker knowledge and skills, here are some related articles you may find helpful:

  1. Introduction To Containerization: Learn about the basics of containerization and how it revolutionizes application development and deployment.

  2. Managing Microservices With Docker Swarm And Kubernetes: Explore the benefits of using Docker Swarm and Kubernetes for managing microservices architecture.

  3. What Is Docker Compose: Dive into Docker Compose, a tool for defining and running multi-container Docker applications.

  4. What Is Docker Hub: Discover the features and advantages of Docker Hub, a cloud-based registry for Docker images.

  5. Docker Vs Kubernetes: Which Container Orchestration Tool Should You Choose?: Understand the differences between Docker and Kubernetes and choose the right container orchestration platform for your needs.

Keep exploring the world of containers and make the most out of Docker in your development workflow. Happy containerization!

Note: If you encounter any issues during the installation process or have questions, refer to the Docker documentation or seek assistance from the Docker community.

Ruslan Osipov
Written by author: Ruslan Osipov