Installing Docker with WSL on Windows 10/11

This note will provide detailed steps and instructions to install Docker and signup for a DockerHub account on Windows with WSL. 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 (WSL).

  1. Register for a Docker Hub account
  2. Download and install all pending Windows OS updates
  3. Run the WSL install script
  4. Reboot your computer
  5. 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.
  6. Manually Installing a Distribution
    If for some reason Windows did not prompt you to create a distribution or you simply would like to create a new one, you can do so by running the following command:
    wsl --install -d Ubuntu
  7. Install Docker Desktop
  8. Double-click the Docker Desktop Installer from your Downloads folder
  9. Click “Install anyway” if warned the app isn’t Microsoft-verified
  10. Click “OK” to Add a shortcut to the Desktop
  11. Click “Close” when you see Installation succeeded message
  12. Double-click the Docker Desktop icon on your Desktop
  13. Accept the Docker Service Agreement
  14. Docker Desktop will launch for the first time
    • Docker Desktop will launch and present you with a tutorial. You are free to skip this.
  15. Ensure that WSL Integration is Enabled
    • In Docker Desktop, click the Settings Gear icon. Then choose Resources, and finally WSL Integration. Make sure that the Enable Integration with my default WSL distro is checked. Also, if you are using multiple distributions, make sure that these additional distros are toggled on:
  16. Open your Distro
    • Using the Windows Search feature in the toolbar, type the name of your distribution (by default it is Ubuntu) and click Open:
  17. Check that Docker is working
    • Using the terminal for your distro, run the docker command. If all is well you should see some helpful instructions in the output similar to below:
  18. Log in to Docker
    • Using the terminal for your distro, 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.
  19. Appendix

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 using the Windows Search feature in the toolbar and typing the name of your distribution (by default it is Ubuntu) and clicking open (see step #16 above).  This terminal should automatically open to the home directory on the Linux filesystem

Going forward, all Docker commands should be run within WSL and not on the Windows file system

Câu chuyện về chiếc xe bị dị ứng với kem vani

Dành cho các kỹ sư của chúng ta, những người hiểu rằng điều hiển nhiên không phải lúc nào cũng đúng và rằng sự thật dù có viển vông đến đâu vẫn là sự thật …

Bộ phận Pontiac của General Motors đã nhận được khiếu nại:

“Đây là lần thứ hai tôi viết thư cho bạn và tôi không trách bạn đã không trả lời tôi. Bởi vì tôi nghe có vẻ hơi điên rồ, nhưng thực tế là gia đình chúng tôi có truyền thống ăn kem tráng miệng sau mỗi bữa tối. Nhưng có nhiều loại kem khác nhau, nên mỗi tối, sau khi chúng tôi ăn xong, cả gia đình sẽ bình chọn loại kem chúng tôi nên ăn và tôi lái xe xuống cửa hàng để mua. Gần đây, tôi đã mua một chiếc Pontiac mới và kể từ đó, tôi đã gặp một vấn đề. Đó là mỗi khi tôi mua kem vani, xe của tôi sẽ không nổ máy. Nếu tôi mua bất kỳ loại kem nào khác, xe vẫn khởi động bình thường. Tôi muốn bạn biết rằng tôi rất nghiêm túc với câu hỏi này, bất kể nó nghe có ngớ ngẩn đến mức nào: ‘Có gì đó ở Pontiac khiến nó không thể khởi động khi tôi mua kem vani và dễ dàng khởi động khi tôi mua bất cứ loại nào khác? ‘”

Pontiac đã nghi ngờ về bức thư, nhưng dù sao họ cũng đã cử một kỹ sư đến kiểm tra. Sau đó, anh ấy rất ngạc nhiên khi được chào đón bởi một người đàn ông thành đạt, có học thức tốt trong một khu phố tốt. Anh ta đã sắp xếp để gặp người đàn ông ngay sau giờ ăn tối, rồi cả hai lên xe và lái đến cửa hàng kem. Họ vào mua món kem vani và sau khi họ quay lại xe, xe không thể nổ máy.

Người kỹ sư trở lại trong ba đêm nữa. Đêm đầu tiên, người đàn ông mua kem sô cô la. Xe nổ máy. Đêm thứ hai, kem vị dâu. Xe nổ máy. Đêm thứ ba anh ta gọi vani. Xe không nổ máy được.

Giờ đây, người kỹ sư, là một người logic, không thể tin rằng chiếc xe của người đàn ông này bị dị ứng với kem vani. Do đó, ông đã tiếp tục các chuyến thăm của mình, để giải quyết vấn đề này. Anh ấy bắt đầu ghi chép: anh ấy ghi lại tất cả các loại dữ liệu, thời gian trong ngày, loại xăng sử dụng, thời gian lái xe qua lại, v.v.

Trong một thời gian ngắn, anh ta đã có manh mối: người đàn ông mất ít thời gian hơn để mua kem vani hơn bất kỳ loại kem nào khác. Tại sao? Câu trả lời là trong cách bài trí của cửa hàng.

Vanilla, là hương vị phổ biến nhất, có trong một hộp riêng ở phía trước cửa hàng để lấy nhanh. Tất cả các hương liệu khác được giữ ở phía sau cửa hàng tại một quầy khác, nơi mất nhiều thời gian hơn để tìm và mang ra ngoài.

Bây giờ câu hỏi đặt ra cho người kỹ sư này là tại sao chiếc xe không khởi động khi nó mất ít thời gian hơn. Thời gian mới là vấn đề – không phải kem vani – người kỹ sư nhanh chóng đưa ra câu trả lời: khóa hơi. Nó diễn ra hàng đêm, nhưng thời gian chờ để mua kem vị khác đã cho phép động cơ hạ nhiệt đủ để khởi động. Khi người đàn ông mua kem vani, động cơ vẫn còn quá nóng để khóa hơi nhả ra.

Bài học rút ra: Ngay cả những vấn đề tưởng như điên rồ đôi khi cũng có thật.

Nguồn: http://www.cgl.uwaterloo.ca/smann/IceCream/humor.html