DevOps Classroom notes 12/Sep/2026

Docker arguments

  • arguments will be used to modified values at build time
ARG java_version=17
ARG mvn_command="clean test"
FROM ubuntu:latest

ARG java_version=17
ARG mvn_command="clean test"

ARG WORKDIR=/home/ubuntu/

RUN mvn ${mvn_command}

RUN apt-get update && apt-get install openjdk-${java_version}-jdk -y

build docker image and arg value

docker build  --build-arg java_version=21 --build-arg mvn_command="clean package" -t javabase:latest .

keypoints:

  • arg values existing during the runtime only (inside Dokcerfile only)
  • we can use desfult values or we can change wile buid image --build-arg
  • any build instruction you can add arguments
  • use build time only arg. if need runtime need use ENV.

Labels:

  • labels are key value pairs (metadat) (image details maintainer, projectname, application name )

adding label to Dockerfile

FROM ubuntu 

LABEL key=value

LABEL app_version=1.0

LABEL author=ramjagadeesh

LABEL project=devops

most common labels using org

  • mainatainer=devops-platform
  • version=1.0.0
  • description=“used for java applications”
  • team_name=“platform”
LABEL  mainatainer=devops-platform \
       version=1.0.0 \
       description="used for java applications"\
       team_name="platform"

Add label at run time

docker run -dit --name nginx --label enviromet=dev nginx:latest

validate or inspect labels from conatiner

docker inspect --format='{{json .Config.Labels}}' nginx

out put

{"enviromet":"dev","maintainer":"NGINX Docker Maintainers <docker-maint@nginx.com>"}

Task

using spring-petclinic & nopCommerce

  1. create Docker image with using args, env, labels a. use common lables b. use arg for packages like java, maven other installtion c. add env like java path , jar files name , app version …etc
  2. run container do the inspect get lables, env, args

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube