DevOps Classroom Series – 01/Sept/2021

Dockerfile contd..

  • ARG :
    • This instruction can be helpful in defining the variable and pass argument during build time
    • The arguments can be passed from docker command line “`docker image build –build-arg <arg>=value
    • Refer Here for the changes Preview
  • ENV: This instruction sets the environmental variable and is available while running the container and this can be changed while running your container
  • Refer examples done inthe class
  • Exercise: Try to fix the container not starting issue with the following dockerfile
FROM openjdk:11-slim
LABEL author="khaja ibrahim"
LABEL organization="quality thought"
ENV APPLICATION_PATH="/spring-petclinic.jar"
ENV TEST_ENV="hello"
CMD [ "java", "-jar", ${APPLICATION_PATH} ]

  • ESCAPE: The escape directive sets the escape characters in the Dockerfile. If not specified the default escape is \
  • Sample dockerfile
FROM ubuntu:bionic
LABEL author='khaja'
RUN export DEBIAN_FRONTEND=noninteractive `
    && apt update && apt install apache2 -y `
    && apt install php libapache2-mod-php php-mysql -y `
    && apt install php-cli -y
COPY info.php /var/www/html/info.php
WORKDIR /var/www/html
ENTRYPOINT [ "echo" ]
CMD [ "helloworld" ]

  • Exercise: There is a sample python code Refer Here

  • Manual Steps:

  • Try to create a Dockerfile with all the necessary instructions to create an image for basicflask

  • Few sessions earlier we have created a Dockerfile for gameoflife, which needed tomcat to work.

FROM tomcat:jdk8
LABEL author="khaja"
ADD /usr/local/tomcat/webapps/gameoflife.war
  • In this Dockerfile we have not written ENTRYPOINT/CMD because we want to use base images CMD.

Leave a Reply

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

About learningthoughtsadmin