Install Docker in Windows and deploy Spring boot Micro Service

Download docker (Docker Desktop Installer) which is specific to windows version https://hub.docker.com/editions/community/docker-ce-desktop-windows
Install the downloaded file, in my case I have unselected Use the WSL 2 based engine in Docker settings and used Hyper-V in windows

Hyper-V installation
Go to windows Apps and Features →Turn windows features on or off →Select Hyper-V and click Ok which take sometime for installation

Then check docker version using docker — version to verify docker installation and then start docker using command start docker
Next Create Spring Boot micro service then add Docker file as like below (if you are using java 8 then in the Docker file mention as From java:8). Docker file is a text document which contains commands to assemble an image


And then build your application normally using mvn command
mvn clean package
which will create jar in target folder
Next build a docker image for the Spring boot Service using below command docker image build -t imagename .

Next we can check the created docker image using below command
docker images

Next use the Docker run command to create container from above created image and starts the same (port is optional here if we specified in application.properties)
