DevOps Classroomnotes 04/Feb/2022

Activity 3 Contd

  • Inspecting the Images created, one extra layer is added as a result of the ADD instruction
  • The final Dockerfile which we have used is
FROM openjdk:11.0.13-jre-slim
LABEL author="khaja"
ADD /spring-petclinic.jar
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
  • Now let run the container with newly builded image
  • Now navigate to openport and add /gameoflife
  • 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
  • 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
CMD ["Hello Docker"]

* 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
  • Lets add one instruction
FROM alpine
ENV MY_NAME=activity6
CMD set

* 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

Leave a Reply

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

About continuous learner

devops & cloud enthusiastic learner