Create a simple DOCKER image and Execute it in the Widows Platform
This document is demonstrated step by step methodology i.e. how to install docker, create docker image, and run the Docker instance in the Windows platform.
Install the Docker Tool Box in the Windows machine.
Need to download the software from this https://www.docker.com/products/docker-toolbox
For your reference please find below image snapshots.
After that, you need to double click on the ‘
DockerToolbox.exe ‘’ .exe file. While this .exe is running it will check ORACLE
VM VIRTUAL BOX is present or not. If it is not present then need to install
this software in your machine otherwise then need to check the checkbox of
coming window boxes. Please find the below screenshot for your reference.
Now double click on the ‘Docker Quickstart Terminal’’ icon
on the desktop. After successfully running this program it will show below messages
that the Docker terminal is running properly.
Now open spring boot ID and create a simple rest controller
service or project from this IDE and run this project from the Spring tool suite Id. Please find the screenshot for your reference.
Now open the browser with URL http://localhost:8080/rsetcontroler, it will display the message like "Welcome to Docker world"
Now I am showing the same
thing with the Docker tool. Please find out the below screenshot for your
reference.
Need to create war (SpringDockerTest-0.0.1-SNAPSHOT.war)
file using the Maven clean and install command.
Now create a folder ‘’DockerTest’’
in any drive in your local machine. And copy the SpringDockerTest-0.0.1-SNAPSHOT.war
into this folder.
Now create a simple docker file ‘Dockerfile’ (don’t give any
extension) in ‘’DockerTest’’ folder and
write down following contents in this file
FROM java:8
EXPOSE 8080
ADD /SpringDockerTest-0.0.1-SNAPSHOT.war
springdockertest.war
ENTRYPOINT ["java","-jar","springdockertest.war"]
Now go to Docker quick start terminal window. And execute
the following command
from the command prompt, it will show existing images that are already created.
$ Docker images
Now create the new docker image and apply the below command
$ docker build -f Dockerfile -t springdockertest .
Now check whether the image is created or not. Apply the below
command again.
$docker images
Springdockertest image is created with image id f495dd93e87d.
Now run the Springdockertest image file and using the below
command.
$ docker run -p 8080:8080 -t springdockertest
Now spring boot simple rest controller service is running under
the Docker. Please see the below screenshot for your reference.
After executing the
below command to get docker-machine IP.
$ docker-machine
ls
NAME ACTIVE
DRIVER STATE URL SWARM DOCKER
ERRORS
default *
virtualbox Running tcp://192.168.99.100:2376
v17.06.0-ce
Now apply the below
URL in the URL bar.
http://192.168.99.100:8080/rsetcontroler
Comments
Post a Comment