DevOps Classroomnotes 11/Jun/2022

Install Docker on a linux machine

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

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

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

Preview

Image Building process

  • overview:
    Preview

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

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

Automated Approach

  • We need to create Dockerfile.
  • The Dockerfile has set of instructions
<INSTRUCTION> VALUE
  • Sample Dockerfile
FROM openjdk:11
LABEL author=khaja
RUN wget https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/spring-petclinic-2.4.2.jar
EXPOSE 8080
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 https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/gameoflife.war
  • Refer Here for the tomcat image
FROM tomcat:9.0.64-jdk8-temurin-focal
LABEL author=khaja
LABEL why=forfun
RUN curl https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/gameoflife.war --output /usr/local/tomcat/webapps/gameoflife.war
EXPOSE 8080

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

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube