beginnerDockerfile Instructions & Multi-Stage Builds
How would you pass a different JAR file name into the build without editing the Dockerfile?
Declare an ARG with a default, e.g., ARG JAR_FILE=target/*.jar, then reference it in COPY: COPY ${JAR_FILE} app.jar. At build time, override it with docker build --build-arg JAR_FILE=target/myapp-2.0.jar . — useful for CI pipelines that build multiple variants from one Dockerfile.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response