Depricated code in Dockerfile for Java language-specific guide
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- docker, docker-compose, java, spring-boot
- Lĩnh vực
- devops, documentation
Hướng nghiên cứu
Bắt đầu từ hướng dẫn Java tại https://docs.docker.com/guides/java/ và kiểm tra Dockerfile của hướng dẫn, đặc biệt là các giai đoạn trích xuất và chạy. So sánh các lệnh với hướng dẫn được liên kết về Dockerfile cho Spring Boot và kiểm tra Dockerfile đính kèm; công việc hoàn tất khi có thể build hướng dẫn và khởi chạy container bằng lệnh được ghi trong tài liệu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is this a docs issue?
- My issue is about the documentation content or website
Type of issue
Information is incorrect
Description
1. Depricated -Djarmode in Spring Boot 4.1+ (?3.5+)
Following the guide a command:
docker compose up --build
,throws an error:
=> ERROR [extract 2/2] RUN java -Djarmode=layertools -jar target/app.jar 1.0s
[extract 2/2] RUN java -Djarmode=layertools -jar target/app.jar extract --destination target/extracted:
0.939 Error: Unsupported jarmode 'layertools'
0.939
Dockerfile:53
RUN java -Djarmode=layertools -jar target/app.jar extract --destination target/extracted
2. Copying extracted files into the runtime image’s filesystem root
After solving the first error, ocсurs a second one:
=> CACHED [extract 2/2] RUN java -Djarmode=tools -jar target/app.jar ext 0.0s
=> ERROR [final 3/6] COPY --from=extract build/target/extracted/dependen 0.0s
[final 3/6] COPY --from=extract build/target/extracted/dependencies/ ./:
Dockerfile:83
81 |
82 | # Copy the executable from the "package" stage.
83 | >>> COPY --from=extract build/target/extracted/dependencies/ ./
84 | COPY --from=extract build/target/extracted/spring-boot-loader/ ./
85 | COPY --from=extract build/target/extracted/snapshot-dependencies/ ./failed to solve: cannot copy to non-directory: /var/lib/docker/buildkit/containerd-overlayfs/cachemounts/buildkit4075886367/lib
3. The container cannot start because of missed JarLauncher
After solving the second error, ocсurs a third one.
✔ Container spring-petclinic-server-1 Created 0.1s
Attaching to server-1
server-1 | Error: Could not find or load main class org.springframework.boot.loader.launch.JarLauncher
server-1 | Caused by: java.lang.ClassNotFoundException: org.springframework.boot.loader.launch.JarLauncher
server-1 exited with code 1
Docker desktop already has a registered container, but cannot start it.
Log: Error: Could not find or load main class org.springframework.boot.loader.launch.JarLauncher
Location
https://docs.docker.com/guides/java/
Suggestion
After all three changes container runs correct.
1. -Djarmode=tools with "--layers" instead of -Djarmode=tlayertools
The problem is use of depricated "layertools"
Remove support for the deprecated layertools jar mode #48568
Spring Boot / Reference / Packaging Spring Boot Applications / Container Images / Dockerfiles
Right line:
RUN java -Djarmode=tools -jar target/app.jar extract --layers --destination target/extracted
2. Add a workdir for application layers
Gordon's solution is from Spring documentation's example code:
The build fails while copying extracted files into the runtime image’s filesystem root, where they can collide with base-image paths such as /lib; I’ll isolate them under /application and retry.
# Line 68
# Keep the application layers separate from operating-system paths in the base image.
WORKDIR /application
3. Change the ENTRYPOINT
Gordon's solution is from Spring documentation's example code.
Change in the last line in Dockerfile.
From:
ENTRYPOINT [ "java", "org.springframework.boot.loader.launch.JarLauncher" ]
To
ENTRYPOINT [ "java", "-jar", "app.jar" ]
And rebuild the image.
P.S. Attached the final dockerfile in .txt format.
- Ngôn ngữ chính
- Markdown
- Star
- 4.7k
- Fork
- 8.5k
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 148
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của docker/docs
-
[docs-scanner] Inconsistent terminology: 'nested organization' vs 'organization in the company'Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[docs-scanner] SSO overview omits OAT as CLI authentication optionCó thể đã có người làm @dave123981 đã nhận 2 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày
-
status/triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
objectionary/hone-maven-plugin#1340 ·
Maintainer thường phản hồi trong vòng 9 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
coder/xum#7733 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 81/100
Maintainer thường phản hồi trong vòng 1 ngày
-
help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Aethelgard-Systems/agent-postbox#32 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100