Interview Prep/Build Tools (Java, Node.js, Python, .NET)/Java builds (Maven, Gradle, JAR, WAR)

What is the difference between a build artifact and a Docker image?

IntermediateConceptJava builds (Maven, Gradle, JAR, WAR)
Answer

Short answer

A build artifact is the output of compiling/packaging the app — a JAR, WAR, DLL folder, wheel or dist/ bundle. A Docker image packages that artifact together with its runtime and OS libraries (JRE, Node, Python, system packages) and the start command, so it runs the same anywhere a container runtime exists.

Example

Artifact Docker image
Java orders-1.4.0.jar eclipse-temurin:21-jre + JAR + ENTRYPOINT java -jar
Node dist/ + node_modules node:22-alpine + files + CMD node dist/server.js
Stored in Nexus / Artifactory Container registry (ECR, ACR, Harbor, GHCR)
Runs with java -jar on a machine with Java docker run / Kubernetes

How they relate in pipelines

Some teams publish both (JAR to Nexus, image to ECR). Many containerised teams now publish only the image, built in a multi-stage Dockerfile that creates the artifact inside.

What to say in the interview

"The artifact is the packaged application; the image bundles that artifact with its runtime and OS dependencies plus the start command. Artifacts go to Nexus, images to a container registry, and in Kubernetes the image is the unit we deploy."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Java apps: Maven, Gradle, JAR & WAR

More on Java builds (Maven, Gradle, JAR, WAR)