Thursday 23 March 2023

Installing Docker with WSL2 on Windows 10/11

 

This note will provide detailed steps and instructions to install Docker and signup for a DockerHub account on Windows with WSL2. We will need a DockerHub account so that we can pull images and push the images we will build.

Windows 10 & 11 users will be able to install Docker Desktop if their computer supports the Windows Subsystem for Linux (WSL2).

  1. Register for a DockerHub account

Visit the link below to register for a DockerHub account (this is free)

https://hub.docker.com/signup

  1. Download and install all pending Windows OS updates
  2. Run the WSL install script

Note - If you have previously enabled WSL you may skip to step #6

Open PowerShell as Administrator and run the wsl --install command. This will enable and install all required features as well as install Ubuntu.



Official documentation:

https://docs.microsoft.com/en-us/windows/wsl/install#install-wsl-command

  1. Reboot your computer
  2. Set a Username and Password in Ubuntu

After the reboot, Windows will auto-launch your new Ubuntu OS and prompt you to set a username and password.


  1. Install Docker Desktop

Navigate to the Docker Desktop installation page and click the Docker Desktop for Windows button:

https://docs.docker.com/desktop/install/windows-install/


  1. Double-click the Docker Desktop Installer from your Downloads folder
  2. Click "Install anyway" if warned the app isn't Microsoft-verified
  3. Click "OK" to Add a shortcut to the Desktop



  1. Click "Close" when you see Installation succeeded message
  1. Double-click the Docker Desktop icon on your Desktop
  2. Accept the Docker Service Agreement



  1. Docker Desktop will launch for the first time

Docker Desktop will launch and present you with a tutorial. You are free to skip this.



  1. Open the WSL terminal

Using the Windows Search feature in the toolbar, type wsl and click Open



  1. Check that Docker is working

Using the WSL terminal, run the docker command. If all is well you should see some helpful instructions in the output similar to below.



  1. Log in to Docker

Using the WSL terminal run the docker login command. You will be prompted to enter the username and password (or your Personal Access Token) you created earlier when registering for a DockerHub account.



Once you see Login Succeeded, the setup is complete and you are free to continue to the next lecture.


A significant difference when using WSL is that you will need to create and run your project files from within the Linux filesystem, not the Windows filesystem. This will be very important in later lectures when we cover volumes.

You can access your Linux system by running wsl in the Windows Search Bar. The wsl terminal will automatically open to the /mnt/c/Windows/System32 location. This is still the Windows filesystem! You will need to run the cd ~ command to change into your Ubuntu user's home directory on the Linux filesystem.

All Docker commands should be run within WSL and not on the Windows file system.


(Article Reference: Stephen Grider Udemy Course) 

1 comment:

  1. Wow, this is really informative!

    If you're serious about investing in cryptocurrencies, you need a trustworthy exchange like Opris to make sure your transactions are safe and secure. As a leading provider of cryptocurrency exchange software , Opris offers top-of-the-line security measures, user-friendly interfaces, and a wide range of trading options to meet the needs of all types of investors.

    paxful clone script
    binance clone script
    coinbase clone script
    kucoinnclone script
    wazirx clone script
    kraken clone script
    huobi clone script

    ReplyDelete