DevOps Classroom notes 19/May/2026

RUN

  • Run instruction will run the command in the container which is used to build image.
  • RUN instruction will execute any linux command
  • Refer Here for official docs
  • In Docker file when we pass RAW commands to instructions we have two forms
    • shell form: you pass raw command
      bash
      apt update
    • exec form: you convert the raw command into array represntation
      ["apt", "update"]
  • In RUN instruction we prefer shell form
  • IN CMD/Entrypoint we prefer exec form

Exercise 1

  • Lets take ubuntu base image
  • Lets install nodejs
FROM ubuntu:24.04
RUN apt update
RUN apt install nodejs npm -y
  • Build the image
docker image build -t exercise:1 .

  • Practice: Install the same with centos 9 as base image and alpine as base image

Exercise 2

  • Lets take python base image
  • Lets run python –version
  • Dockerfile
FROM python:3-slim
RUN python --version
  • exercise:
    • Try java -version with java image
    • try dotnet –list-runtimes with dotnet images

ADD/COPY

  • ADD or COPY instructions help us in copying content into docker container which is used to build image and will be part of the image
  • ADD supports urls and as well local paths
  • COPY supports only local paths

Exercise 3

  • Lets create an alpine base container where we copy a local text file into image
FROM alpine:3
ADD README.md /README.md
  • Other version
FROM alpine:3
COPY README.md /README.md

Exercise 4

  • Lets create an alpine base container where we copy a file from internet into image
FROM alpine:3
ADD https://templatemo.com/tm-zip-files-2020/templatemo_617_pixel_forge.zip /design.zip

Exercise 5

  • Lets copy the whole folder into docker image
FROM alpine:3
RUN mkdir app
COPY . /app
  • I want to copy a local folder but i dont want Dockerfile to be copied into container and .venv folder to be copied into container
  • Create a file called as .dockerignore and in this file mention the files or folders or types which you dont want to copy
  • Exercise: COPY the fast api code into /app ignore
    • virtual environment
    • Dockerfile
    • .dockerignore
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%%