I tried using Docker Desktop for Windows on Windows 10 Home

Introduction

Hello. This is Hasegawa. Posted as an article on Yayoi Advent Calendar 2020.

As a personal hobby, I tried using Docker Desktop for Windows on Windows 10 Home at home. This time, I wrote an article about preparations for using Docker Desktop for Windows and impressions of using it.

Windows 10 environment at home

・ Windows 10 Home Edition ・ 64-bit version (* WSL cannot be used with 32-bit version!)

How I decided to use it

Originally, I deployed a web application on Google Cloud Platform (GCP) for the purpose of studying technology. At that time, I wanted to use Docker, which is a trend (?) In recent years.

Since Windows 10 on my home PC is a "Home" edition, I can't use Hyper-V. I did a little research on how to use Docker on Windows 10 Home, but I thought that "environment construction seems to be a little troublesome ...", and there was a section that I was a little shy of.

In my lazy ear, "From Windows version 2004, ** WSL2 ** and ** Docker Desktop for Windows ** can be used on Windows 10 Home. You can use it without Hyper-V." Information has jumped in. [^ 1] "I have no choice but to try this!"

* What is WSL2?

Abbreviation for Windows Subsystem for Linux 2. It is a mechanism to run Linux on Windows.

The differences between WSL1 and WSL2 are described in detail in the following Microsoft documentation. https://docs.microsoft.com/ja-jp/windows/wsl/compare-versions

[^ 1]: WSL2 is also available in version 1903/1909 with the cumulative update.
https://forest.watch.impress.co.jp/docs/news/1272017.html

Preparation

To put it briefly, Docker Desktop for Windows is ready to use after the following preparations.

  1. Windows 10 version upgrade
  2. Install Docker Desktop for Windows
  3. Installation of WSL2

1. Windows 10 version upgrade

WSL2 is available from Windows 10 version "2004". [^ 1] I'm lazy, and I've left the update for a long time, so the version remained "1909". When I checked "Settings"-> "Update and Security"-> "Windows Update", I was able to get a new version of Windows, so I updated it without checking it very well. After updating, when I checked the version of Windows, it was "20H2". ** "What? What is H2? Hydrogen ...?" ** After a little research, it was Windows 10 October 2020 Update ... In other words, it is a newer version than "2004". This completes the Windows 10 version upgrade.

2. Install Docker Desktop for Windows

I downloaded and installed Docker Desktop for Windows from the following site. https://hub.docker.com/editions/community/docker-ce-desktop-windows

3. Installation of WSL2

When you launch Docker Desktop for Windows using the previous procedure, the following message will appear ... キャプチャa.PNG "By the way, I didn't have WSL2 installed ..." The order was a little messed up, but I downloaded and installed the "WSL2 Linux Kernel Update Package for x64 Machines" from the following site. https://aka.ms/wsl2kernel

Try using Docker Desktop for Windows

Start-up!

Now that you're ready, start Docker Desktop for Windows. The following screen has been launched. capture_ (5).PNG

This is the screen where a list of running containers is displayed. This is what it looks like now because no container is running. Click "Images" on the left side of the screen to open the following screen. capture_ (6).PNG

A list of Docker images is displayed here. This is what it looks like because there are no images now.

Creating an image

Create the image from the command prompt or Windows PowerShell. For the time being, I wanted to see how it works, so I created the following Dockerfile. Open port 80 and install the Apache and .NET Core SDKs.

FROM centos:7
RUN echo "now building..."
RUN yum -y install httpd
EXPOSE 80
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum -y install dotnet-sdk-3.1

Start a command prompt in the directory where you put the Dockerfile, and execute Docker Build.

cmd.exe


Working directory>docker build -t testmycontainer .
[+] Building 1.8s (9/9) FINISHED
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 32B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for docker.io/library/centos:7                                                        1.8s
 => [1/5] FROM docker.io/library/centos:7@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e  0.0s
 => CACHED [2/5] RUN echo "now building..."                                                                        0.0s
 => CACHED [3/5] RUN yum -y install httpd                                                                          0.0s
 => CACHED [4/5] RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm           0.0s
 => CACHED [5/5] RUN yum -y install dotnet-sdk-3.1                                                                 0.0s
 => exporting to image                                                                                             0.0s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:6c50ce36ff73cec713b16e6384a8cb7d7ce35db507fb92dee249f77f53396bde                       0.0s
 => => naming to docker.io/library/testmycontainer                                                                 0.0s

If you check the list of images with Docker Desktop for Windows ... capture_ (7).PNG

I was able to confirm that the image was created.

Start container

I would like to create a container from the image I created earlier and execute it. When you move the cursor to the line of the image name, the "RUN" button will be displayed. Click it. capture_ (8).PNG

Then, the container name and port selection screen will be displayed. Enter it and click "RUN". capture_ (9).PNG

Then click "Containers/Apps" on the left side of the screen to check the running containers. capture_ (4).PNG

Oh! moving! For the time being, let's check the command with the docker ps command.

cmd.exe


Working directory>docker ps
CONTAINER ID   IMAGE                    COMMAND       CREATED         STATUS         PORTS     NAMES
d1eee1f16576   testmycontainer:latest   "/bin/bash"   2 minutes ago   Up 2 minutes   0.0.0.0:49153->80/tcp    Test

It looks like it's working!

in conclusion

From now on, I think it will be very convenient because I can check if the locally developed program works on Docker even on Windows 10 Home and deploy it in a remote production environment (although it is within the scope of personal play).

When I have time, I would like to keep posting articles such as deployment!

Recommended Posts

I tried using Docker Desktop for Windows on Windows 10 Home
Using Docker on Windows10 Home WSL2
I tried running Docker on Windows Server 2019
Introducing Docker Desktop for Windows on WSL2
I tried using Docker for the first time
Operate Docker Desktop for Windows on Linux (WSL)
Try Docker on Windows 10 Home
Use Docker Compose on Windows 10 Home
Try Docker on Windows Home (September 2020)
A memo when building a Rails 5.2 development environment using Docker Desktop + WSL2 on Windows 10 Home
I tried using Scalar DL with Docker
Microservices 101-I tried putting Docker on Ubuntu-
Installing Docker Desktop on Windows 10 Home was easy and easy (as of December 2020)
I tried using Junit on Mac VScode Maven
[For beginners] I tried using DBUnit in Eclipse
[For beginners] I tried using JUnit 5 in Eclipse
I tried touching Docker for the first time
I tried running Ansible on a Docker container
I tried installing docker on an EC2 instance
I tried using Gson
I tried using TestNG
I tried using Galasa
M.S. docker on Windows
[First environment construction] I tried to create a Rails 6 + MySQL 8.0 + Docker environment on Windows 10.
How to start with Hyper-V instead of WSL2 on Docker Desktop for Windows
I built an Ubuntu environment on Windows 10 using WSL2.
I tried using the Migration Toolkit for Application Binaries
I tried using Log4j2 on a Java EE server
I tried using YOLO v4 on Ubuntu and ROS
[Note] I suddenly can't build with Docker for windows.
I tried using an extended for statement in Java
I installed CentOS 8 on Windows 10 using VirtualBox and Vagrant
I tried to build an environment using Docker (beginner)
Install Docker on Windows 10 PRO
Run openvpn on Docker (windows)
I tried using azure cloud-init
I tried the Docker tutorial!
I tried using Apache Wicket
I tried using Java REPL
I tried BIND with Docker
[Rails] I tried using the button_to method for the first time
I tried to create React.js × TypeScript × Material-UI on docker environment
I tried to build the environment little by little using docker
I tried running a Docker container on AWS IoT Greengrass 2.0
I tried running WordPress with docker preview on M1 Mac.
Configuration script for using docker in proxy environment on ubuntu 20.04.1
I tried using anakia + Jing now
Try Oracle Enterprise Manager Cloud Control with Docker Desktop for Windows
Until you put Ubuntu 20 on Windows 10 Home and WSL2 and run Docker
I tried using Spring + Mybatis + DbUnit
Try using Redmine on Mac docker
I tried using JOOQ with Gradle
I tried to integrate Docker and Maven / Netbean nicely using Jib
Docker on NILFS2 filesystem (for raspbianOS)
[Personal memo] About button (GUI) operation of Docker Desktop for Windows
Building a haskell environment with Docker + VS Code on Windows 10 Home
I tried using Java8 Stream API
I tried deploying a Docker container on Lambda with Serverless Framework
I tried using JWT in Java
WSL2 + Docker Desktop for Windows does not launch only MySQL container
[Android] I tried using Coordinator Layout.