DevOps Classroom notes 31/Jan/2025

Dockerfile contd

  • RUN: This instruction RUNs a command during image building
  • WORKDIR
  • ARG: This is build argument which can be passed during image build
  • ENTRYPOINT:
    • if entrypoint exists in Docker file that will be default executable. whatever we write in CMD will become arguments to entrypoint
    • if entrypoint is not found then CMD will be executable
    • CMD can be overriden easily by passing additional commands post image name in docker run
    • Note: watch classroom video
  • docker run command by default runs in attached mode where as -d will run in detached mode i.e in background
  • We can also run a contaier in an interactive mode
docker run -it alpine /bin/sh

Sample Application – Java

  • Running the application as a non root user
  • Lets create a user called as spc, and copy the jar file into user’s home directory
  • Refer Here for the changes
  • Refer Here for changes to include workdir as /apps
  • Lets parametrize the username and source for downloading petclinic

Shell form and Exec Form

  • Shell form is where you can write the commands directly apt update
  • Exec form is where you follow json array syntax ["apt", "update"]
  • Shell form:
    • in a windows container this runs with CMD
    • in a linux contianer this runs with /bin/sh
    • This can expand variables ${USERNAME}
    • This does not handle SIGTERM i.e. it cannot handle docker stop correctly
    • where to use:
      • RUN
  • Exec form:
    • Runs the command directly
    • No variable expansions
    • This works well with SIGTERM
    • Where to use
      • ENTRYPOINT
      • CMD
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%