DevOps Classroom notes 07/Jan/2024

Dockerfile contd

ADD COPY:

  • To copy the files into docker image
  • Refer Here for ADD and Refer Here for COPY instructions official docs
  • ADD and COPY both copy the files into Docker image where as
    • ADD can copy from local as well remote files into docker image
    • COPY can copy files or folders from local system only
  • Refer Here for the changes done to containerize the game of life application

WORKDIR: Default directory when container starts

  • Refer Here for official docs
  • Lets implement WORKDIR in spring petclinic with /spc
  • Refer Here for the changes

USER

  • Refer Here for USER instruction.
  • Lets run the spring petclinic as non root user Refer Here for the changes done

Parametrization

  • Dockerfile allows paramterization at two levels
    • while building the image
    • while running the container
      • ENV

Buildtime variables using ARG

Envrionmental variables using ENV

SHELL FORM and EXEC FORM

  • Shell form: write the command directly
ping google.com
  • EXEC form: write the command in the following formats
 ["ping", "google.com"]
  • Recommendataions
    • RUN use shell form
    • CMD/ENTRYPOINT: use exec form

Exercise

  • Give me a command to create a linux user which doesnot asks me questions
    • It should create a user with a home director and shell setup
addgroup -g 1000 spc
adduser -h "/spc" -u 1000 -G spc -s /bin/bash -D spc
  • Look into jenkins/jenkins Dockerfile
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%%