DevOps Classroom notes 24/Jun/2025

Docker contd

Dockerfile

  • Dockerfile has instructions to build a docker image

FROM

  • This helps in selecting a base image
  • Experiments
    • Exploring options of FROM
    • choosing different base images

Experiment 1

  • Lets just add FROM statement in Dockerfile
FROM eclipse-temurin:17-jdk
  • pull the base image docker image pull eclipse-temurin:17-jdk and verify images docker image ls
  • Now lets build image
  • Now lets add metadata
FROM eclipse-temurin:17-jdk
LABEL author="khaja"

  • There is a base image called as scratch which is empty
  • Platforms:
    • amd
    • arm

RUN

  • Run instruction executes the command during image building
  • Consider the following Dockerfile
FROM ubuntu:24.04
LABEL author="khaja"
LABEL project="classroom"
RUN apt update &&
    apt install openjdk-17-jdk -y

ADD or COPY

  • ADD can copy files from local as well as web into docker image
  • COPY can copy the local files or folders into docker image
  • Sample Dockerfile
FROM ubuntu:24.04
LABEL author="khaja"
LABEL project="classroom"
RUN apt update && \
    apt install openjdk-17-jdk -y

ADD https://referenceappslt.s3.ap-south-1.amazonaws.com/spring-petclinic-3.3.0-SNAPSHOT.jar /spring-petclinic-3.3.0-SNAPSHOT.jar

ENTRYPOINT/CMD

  • This is used to start the application

Note

  • Remove all images docker image rm -f $(docker image ls -q)
  • When we create a container, container searches for start up command (CMD) if not found searches in base image startup
  • container is running as long as startup command is in running state
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

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

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%