DevOps Classroomnotes 04/Feb/2022

Activity 3 Contd

  • Inspecting the Images created, one extra layer is added as a result of the ADD instruction
    Preview
  • The final Dockerfile which we have used is
FROM openjdk:11.0.13-jre-slim
LABEL author="khaja"
ADD https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/spring-petclinic-2.4.2.jar /spring-petclinic.jar
EXPOSE 8080
CMD [ "java", "-jar", "/spring-petclinic.jar" ]

Activity 4

  • Containerize an application which runs on tomcat 8 server
  • Manual Steps:
  • Ensure JAVA 8 is installed
  • Ensure Tomcat 9 is installed
  • COPY the game-of-life.war in the webapps folder of tomcat8
  • tomcat runs on port 8080 by default
  • Refer Here for the changes done
  • Now build the image
    Preview
    Preview
  • Now let run the container with newly builded image
    Preview
  • Now navigate to openport and add /gameoflife
    Preview
  • Exercise: Try building a slim version of gameoflife with 9 and jdk you can probably use tomcat:9-jdk8-openjdk-slim

Activity 5

  • Create a Docker container with any base image of your choice which will print Hello Docker when the container is STARTED
FROM alpine
CMD ["echo", "Hello Docker"]
  • Lets do some experiments
    Preview
    Preview
  • Whatever is written in CMD can be overriten by passing arguments after image name in docker container run docker container run actvity5:1.0 <any command>
  • Now consider the following dockerfile
FROM alpine
ENTRYPOINT ["echo"]
CMD ["Hello Docker"]

Preview
* ENTRYPOINT is the fixed command that gets started when container is created and cannot be overriten whereas whatever is written in CMD can be overriten

Activity 6

  • Create a docker container that will print all the environment variables when container is started
  • Solution
FROM alpine
CMD set
  • Now run the container
    Preview
  • Lets add one instruction
FROM alpine
ENV MY_NAME=activity6
CMD set

Preview
* If your application depends on any ENV variables, we can add them by using the Dockerfile using ENV instruction.
* We can also change the ENV variable while creating the container
Preview

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