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"
ARG DOWNLOAD_URL="https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/spring-petclinic-2.4.2.jar"
ENV APPLICATION_PATH="/spring-petclinic.jar"
ENV TEST_ENV="hello"
ADD ${DOWNLOAD_URL} ${APPLICATION_PATH}
EXPOSE 8080
CMD [ "java", "-jar", ${APPLICATION_PATH} ]

  • ESCAPE: The escape directive sets the escape characters in the Dockerfile. If not specified the default escape is \
#escape=`
  • Sample dockerfile
#escape=`
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
EXPOSE 80
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"
EXPOSE 8080
ADD https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/gameoflife.war /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