$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
JavabeginnerNew

Java Docker

Share

Create optimized Docker image for Java/Spring Boot apps

Works with OpenClaude

You are a Java/Spring Boot DevOps engineer. The user wants to create an optimized Docker image for their Java or Spring Boot application using best practices.

What to check first

  • Verify your project has a pom.xml (Maven) or build.gradle (Gradle) file in the root
  • Check that you have Docker installed: docker --version
  • Confirm your Java application has a main class and can run: mvn clean package or gradle build

Steps

  1. Add the Google Jib Maven plugin to your pom.xml in the <plugins> section under <build> to enable containerization without writing a Dockerfile
  2. Configure Jib with your target image registry (Docker Hub, GCR, or local Docker daemon) using <configuration> tags
  3. Set the base image to eclipse-temurin:21-jre or openjdk:21-slim for a lightweight JVM runtime
  4. Configure Jib to split layers: app dependencies, resources, and classes separately for better caching
  5. Add JVM flags like -XX:+UseG1GC and -XX:MaxRAMPercentage=75.0 in Jib's <jvmFlags> for production optimization
  6. Build the image using mvn compile jib:build for remote registry or mvn compile jib:dockerBuild for local Docker
  7. Test the image: docker run --rm -p 8080:8080 your-image-name:latest
  8. Verify logs and health endpoints respond correctly before pushing to production

Code

<!-- Add to pom.xml -->
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>spring-boot-app</artifactId>
  <version>1.0.0</version>

  <properties>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>jib-maven-plugin</artifactId>
        <version>3.4.0</version>
        <configuration>
          <from>
            <image>eclipse-temurin:21-jre</image>
          </from>
          <to>
            <image>docker.io/your-username/spring-boot-app</image>
            <tags>latest,1.0.0</tags>
          </to>
          <container>
            <jvmFlags>
              <jvmFlag>-XX:+UseG1GC</jvmFlag>
              <jv

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryJava
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
javadockerjib

Install command:

curl -o ~/.claude/skills/java-docker.md https://claude-skills-hub.vercel.app/skills/java/java-docker.md

Related Java Skills

Other Claude Code skills in the same category — free to download.

Want a Java skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.