dev-resources.site
for different kinds of informations.
Docker Installation Log for WSL 2 on Windows
Published at
8/19/2024
Categories
docker
junior
code
wsl
Author
eddiegulay
Author
10 person written this
eddiegulay
open
I just started to learn about docker and i thought it will be a good idea to document the process. So here’s a concise yet descriptive log documenting the process of installing and configuring Docker entirely within WSL 2 on Windows. Each step includes a brief explanation of the purpose of the commands and the tools being installed.
1. Install and Configure WSL 2
- Install WSL (Windows Subsystem for Linux):
wsl --install
- Purpose: Installs WSL, allowing you to run a full Linux kernel on your Windows machine.
- Context: WSL enables a Linux environment directly within Windows, and WSL 2 uses a real Linux kernel for better compatibility and performance.
-
Install a Linux Distribution (e.g., Ubuntu):
- Action: Download and install Ubuntu from the Microsoft Store.
- Purpose: Ubuntu provides a familiar Linux environment where Docker will be installed.
Set WSL 2 as the Default Version:
wsl --set-default-version 2
- Purpose: Ensures that new WSL instances use WSL 2, which offers improved performance and full system call compatibility.
-
Launch the Linux Distribution:
- Action: Open the installed Ubuntu distribution.
- Purpose: This opens the Ubuntu terminal where all subsequent commands will be run.
2. Update and Install Prerequisites
- Update Package Information:
sudo apt update && sudo apt upgrade
- Purpose: Updates the package lists and installs the latest versions of all installed packages.
- Context: Ensures that your system is up-to-date before installing Docker.
- Install Required Packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
-
apt-transport-https: Allows
apt
to use HTTPS for downloading packages, improving security. - ca-certificates: Ensures that your system trusts SSL certificates, necessary for secure communications.
- curl: A command-line tool for transferring data with URLs, used to download the Docker GPG key.
- software-properties-common: Provides tools for managing software repositories, enabling the addition of Docker’s repository.
3. Add Docker’s Official GPG Key and Repository
- Add Docker GPG Key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Purpose: Fetches and stores Docker’s GPG key, which is used to verify the authenticity of Docker packages.
- Context: This step ensures that the Docker packages you install are legitimate and haven’t been tampered with.
- Set Up Docker’s APT Repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
-
Purpose: Adds Docker’s official stable repository to your system’s package sources, allowing
apt
to download Docker directly from Docker’s servers. - Context: Docker’s official repository contains the latest, stable versions of Docker.
4. Install Docker
- Install Docker Engine and Related Tools:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
- docker-ce: The Docker Community Edition, the core engine that runs Docker containers.
-
docker-ce-cli: Command-line tools for interacting with Docker, such as
docker run
anddocker ps
. - containerd.io: A container runtime that manages the lifecycle of containers, responsible for running and supervising containers.
5. Start and Enable Docker
- Start Docker Service:
sudo service docker start
- Purpose: Manually starts the Docker service, making Docker operational on your WSL environment.
- Enable Docker to Start on Boot:
sudo systemctl enable docker
- Purpose: Configures Docker to start automatically whenever the WSL environment is launched.
6. (Optional) Allow Non-Sudo Docker Usage
- Add User to Docker Group:
sudo usermod -aG docker $USER
-
Purpose: Adds your user to the Docker group, allowing you to run Docker commands without using
sudo
. - Context: This step is optional but recommended for convenience. After running this command, log out and back in to apply the changes.
7. Verify Installation
- Check Docker Version:
docker --version
- Purpose: Confirms that Docker is installed correctly by displaying the installed version.
- Run a Test Container:
docker run hello-world
- Purpose: Runs a test container to verify that Docker is functioning properly within your WSL environment.
Diving to more chaose ...
peace ✌🏾🕊️
wsl Article's
30 articles in total
Update WSL Ubuntu password
read article
Building OpenCV 4.10.0 with GUI Support in WSL
read article
Video: Install Ubuntu using WSL 2
read article
Install Zellij on WSL
read article
Work from anywhere with VSCode Remote Tunnels
read article
SSL verification error at depth 2 - Zscaler | WSL
read article
Accelerate 1-bit LLM Inference with BitNet on WSL2 (Ubuntu)
read article
Just start using WSL
read article
Change WSL/Docker files to another disk
read article
Setup your laravel 11 in windows
read article
Install Ubuntu on WSL 2
read article
How to Install WSL from PowerShell on Windows 10 and 11
read article
WSL in AWS Windows Server 2022 Core instance
read article
Docker Installation Log for WSL 2 on Windows
currently reading
Enable WSL shell in GitHub Desktop
read article
Installing Ruby using rbenv on your WSL Ubuntu system
read article
How to Install Redis on Windows Using WSL2
read article
PowerShell Development in Neovim
read article
WSL: Gerenciando o disco da distro
read article
Docker
read article
Share Postgresql from Windows to WSL Linux
read article
Add Manjaro into WSL 2
read article
Using WSL2 as primary driver for 3 months with Fedora
read article
Wsl installation error
read article
Install Debian in Different Location -WSL Windows
read article
Monitor GPU Usage in WSL debian
read article
Dicas e configurações para seu sistema linux
read article
Instalando de maneira rápida e eficiente suas ferramentas no WSL. Pt-3
read article
Arch install azure cli
read article
Melhorando e configurando seu novo Shell linux. Pt-2
read article
Featured ones: