DevOps Classroom Series – 27/Jan/2020

Manual Creation of Apache Server

  • Scenario: Creating an Apache Server
  • Sol:
    • Create an ubuntu server
    • ssh into ubuntu server
    • execute the following commands
    sudo apt-get update
    sudo apt-get install apache2 -y

Creating a Docker Image for Apache Server

  • Approach:
    • Search for ubuntu in Docker hub to choose base image
    • Execute some commands while building apache image (to convert base image into apache server image)
    sudo apt-get update
    sudo apt-get install apache2 -y
  • Solution:
    • Create a file with name Dockerfile and add following contents
    FROM ubuntu
    RUN "apt-get update"
    RUN "apt-get install apache2 -y"
    • Using this Dockerfile build a docker image using
    docker image build -t myapache .

Installing Docker on Linux Platforms

  • Simple Approach:
    • Always installs the latest version
    curl -fsSL -o
    • add user to the Docker Group
    sudo usermod -aG docker <username>
    • Logout and login into the linux machine
    docker info

Manual Creation of Spring-Petclinic (Spring Boot)

  • Install JAVA
  • Download Spring pet clinic from here
  • Run the command java -jar spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar

Docker image creation for Spring-Petclinic

  • Find a base-image with java already installed. In this example i would be using openjdk:8
  • Dockerfile
FROM openjdk:8
RUN wget
CMD ["java", "-jar", "spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar"]
  • Build the image
docker image build -t spc .
docker image ls
  • Create the container from image
docker container run -d -p 8081:8080 spc
docker container ls

Dockerfile Instructions

  • Instructions are phrases in the Dockerfile with some Behaviors
  • For complete list of instructions refer here
  • FROM => to choose the base image
  • RUN => execute the command while building the image
  • EXPOSE => to expose ports used by container
  • CMD => command to be executed while container creation

Leave a Reply

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

About learningthoughtsadmin