DevOps Classroomnotes 11/Jun/2022

Install Docker on a linux machine

curl -fsSL -o

* After installing docker, the connection between client and docker engine is not working due to permission issue
* Option 1: run docker as root user
* Option 2: Add current user to the docker group

sudo usermod -aG docker <username>
# exit and relogin


Image Building process

  • overview:

Manual approach

  • To build a image that runs our application, we need to know the manual steps of running our application.
  • In this case, lets consider the application to be spring pet clinic.
    • runtime: Java 11 (JDK 11)
    • software package Refer Here
    • runs on port 8080
  • To build a image we will be using existing image, When we pick the existing image for our application
    • option 1: take a image and install runtime and download package
    • option 2: take a image which already has a runtime & download and run application.
  • We have opted for option 2 and chosen openjdk:11 (image:tag).
  • Lets create a container and login into it
docker container run -p <port of linux>:<port of application> -it <image>:<tag> <terminal>
docker container run -p 8080:8080 -it openjdk:11 /bin/bash

* Now exit after downloading the application
* Now in this container we have spring petclinic
* Now lets create image from container

Automated Approach

  • We need to create Dockerfile.
  • The Dockerfile has set of instructions
  • Sample Dockerfile
FROM openjdk:11
LABEL author=khaja
RUN wget
CMD ["java", "-jar", "/spring-petclinic-2.4.2.jar"]
  • In the above Dockerfile the instructions are
    • FROM
    • LABEL
    • RUN
    • EXPOSE
    • CMD
  • This Dockerfile when executed with docker image build -t <image>:<tag> <directory with docker file> will try to create a container based on base image and run all the necessary instructions and creates the image
  • When we start the container from image whatever is mentioned in CMD/ENTRYPOINT gets executed.
  • Lets try to create one more application gameoflife. This application requires
    • server: tomcat
    • runtime: java 8
    • port 8080
    • Download gameoflife into webapps
  • Refer Here for the tomcat image
FROM tomcat:9.0.64-jdk8-temurin-focal
LABEL author=khaja
LABEL why=forfun
RUN curl --output /usr/local/tomcat/webapps/gameoflife.war

  • Lets build to create image
  • Refer Here for Dockerfile Instructions

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner