DevOps Classroom Series – 19/Mar/2021


  • Docker can build images by reading instructions from a Dockerfile
  • Lets take one more application as an example
    • This application is based on java
    • This application runs on port 8080
  • Lets try to install this java application on a linux machine first
  • create a ubuntu linux vm on any cloud. login into linux machine using ssh
    • install java
    • download spring pet clinic application
sudo apt update
sudo apt install openjdk-8-jdk -y
java -version
java -jar spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar
  • Now navigate to http://publicip:8080 Preview
  • To create a docker
    • We have to choose a right base image
      • You can choose ubuntu and perform all the steps
      • Choose a image where java is already installed
  • To build Dockerfile we will be using instructions Refer Here
  • So lets build a Dockerfile using ubuntu:18.04 image
    • To set the base image we will be using FROM instrution Refer Here
    • Now we need to divide our commands which we use to install/configure our application into two sections
      • application installation/configuration steps. All the configuration steps we will be using can be written in Dockerfile with RUN instruction Refer Here
      apt update
      apt install openjdk-8-jdk wget -y
      • application execution steps. Execution steps will be configured with instruction CMD Refer Here
      java -jar spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar
      • Our application when executed might require some port to connect, in this case the port is 8080, we use EXPOSE instruction to specify ports of application Refer Here
  • Create a folder and then place the Dockerfile in it. Now build the docker image using docker image build command Refer Here
docker image build -t spc:ubuntu .


  • Now lets check the docker images in the local machine (local repository) docker image ls Refer Here Preview
  • Building a Image using openjdk image
  • To copy the jar file into container use the ADD instruction Refer Here
  • Lets try to build the docker image
docker image build -t spc:openjdk .


  • Lets view the docker image in the local registry Preview
  • Now lets try to run the application in a docker container using two images which we have built Preview Preview Preview
  • To build a docker image for an app we will have multiple approaches, try to use the approach which is simpler and which results in consuming less resources
  • Refer Here for the dockerfiles used in the class room
  • Refer Here for the slim version of spc

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin