Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVM libzip.so file lost #80

Open
tao12345666333 opened this issue May 30, 2019 · 4 comments
Open

JVM libzip.so file lost #80

tao12345666333 opened this issue May 30, 2019 · 4 comments

Comments

@tao12345666333
Copy link

Thanks for this tool.

When I want to try docker-slim, I have a problem, I want to confirm if there is a problem with my usage, or is this a bug.

My Dockerfile is here

FROM maven:3.6.1-jdk-8-alpine AS builder

WORKDIR /app

COPY pom.xml /app/
RUN mvn dependency:go-offline
COPY src /app/src
RUN mvn -e -B package

FROM builder AS dev

RUN apk add --no-cache vim

FROM openjdk:8-jre-alpine

COPY --from=builder /app/target/gs-spring-boot-0.1.0.jar /

CMD [ "java", "-jar", "/gs-spring-boot-0.1.0.jar" ]

you can find it on https://github.com/tao12345666333/spring-boot-hello-world/blob/master/Dockerfile

(MoeLove) ➜  ~ sudo docker-slim  build  --http-probe local/spring-boot:1
[sudo] tao 的密码:
docker-slim[build]: state=started   
docker-slim[build]: info=params target=local/spring-boot:1 continue.mode=enter
docker-slim[build]: state=inspecting.image
docker-slim[build]: info=image id=sha256:01e4898d1141763400d39111609425ba6232b8bf42f46a6033fdb2b7306dc75b size.bytes=103166686 size.human=103 MB
docker-slim[build]: info=image.layers index=0 name='local/spring-boot' tags='1'                 
docker-slim[build]: state=inspecting.container                                                                                                                                                                      
docker-slim[build]: info=container status=created id=32b94537fe4fb4b68b0278384f7857d2a2a87b1bbf76dfb63dd3c98ac047ea58
docker-slim[build]: info=cmd.startmonitor status=sent                         
docker-slim[build]: info=event.startmonitor.done status=received     
docker-slim[build]: info=container name=dockerslimk_17626_20190530031807 id=32b94537fe4fb4b68b0278384f7857d2a2a87b1bbf76dfb63dd3c98ac047ea58 target.port.list=[] target.port.info=[]
docker-slim[build]: info=prompt message='press <enter> when you are done using the container'
                              
docker-slim[build]: state=processing
docker-slim[build]: state=building message='building minified image'
docker-slim[build]: state=completed       
docker-slim[build]: info=results status='MINIFIED BY 3.48X [103166686 (103 MB) => 29652590 (30 MB)]'
docker-slim[build]: info=results  image.name=local/spring-boot.slim image.size='30 MB' data=true
docker-slim[build]: info=results  artifacts.location='/usr/local/bin/.docker-slim-state/images/01e4898d1141763400d39111609425ba6232b8bf42f46a6033fdb2b7306dc75b/artifacts'
docker-slim[build]: info=results  artifacts.report=creport.json
docker-slim[build]: info=results  artifacts.dockerfile.original=Dockerfile.fat
docker-slim[build]: info=results  artifacts.dockerfile.new=Dockerfile
docker-slim[build]: info=results  artifacts.seccomp=local-spring-boot-seccomp.json
docker-slim[build]: info=results  artifacts.apparmor=local-spring-boot-apparmor-profile
docker-slim[build]: state=done
(MoeLove) ➜  ~ docker run --rm local/spring-boot.slim
Error occurred during initialization of VM
Unable to load ZIP library: /usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/libzip.so
(MoeLove) ➜  ~ docker tag local/spring-boot:1 taobeier/spring-boot-hello-world:1
(MoeLove) ➜  ~ docker push taobeier/spring-boot-hello-world:1

the docker image I have beed pushed to DockerHub taobeier/spring-boot-hello-world:1

@kcq
Copy link
Member

kcq commented May 31, 2019

Thank you for providing the reference project! It'll be much easier to repro!

I noticed you don't have an EXPOSE instruction in your Dockerfile. I assume you use the -p parameter in your docker run command mapping 8080 to a host port...

@tao12345666333
Copy link
Author

I noticed you don't have an EXPOSE instruction in your Dockerfile. I assume you use the -p parameter in your docker run command mapping 8080 to a host port...

So the following error message

(MoeLove) ➜ ~ docker run --rm local/spring-boot.slim
Error occurred during initialization of VM
Unable to load ZIP library: /usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/libzip.so

Is it due to the absence of the expose port?

@tao12345666333
Copy link
Author

After I added expose, the problem still exists.

(MoeLove) ➜  spring-boot-hello-world git:(master) ✗ sudo docker-slim  build  --http-probe local/spring-boot:6
[sudo] tao 的密码:
docker-slim[build]: state=started
docker-slim[build]: info=params target=local/spring-boot:6 continue.mode=enter
docker-slim[build]: state=inspecting.image
docker-slim[build]: info=image id=sha256:8e5ccc8213f5fc3a3134dba8547b6dd543e7ae1ebad55084c334322efa919b15 size.bytes=103166686 size.human=103 MB
docker-slim[build]: info=image.layers index=0 name='local/spring-boot' tags='6'
docker-slim[build]: info=image.exposed_ports list='map[8080/tcp:{}]'
docker-slim[build]: state=inspecting.container
docker-slim[build]: info=container status=created id=8be77d9ce1a969255f7c4280e988235cae9f7dfe70a0c8e3d46f4e4c40f6afa8
docker-slim[build]: info=cmd.startmonitor status=sent
docker-slim[build]: info=event.startmonitor.done status=received
docker-slim[build]: info=container name=dockerslimk_5779_20190531054415 id=8be77d9ce1a969255f7c4280e988235cae9f7dfe70a0c8e3d46f4e4c40f6afa8 target.port.list=[32770] target.port.info=[8080/tcp => 0.0.0.0:32770]
docker-slim[build]: info=prompt message='press <enter> when you are done using the container'


docker-slim[build]: state=http.probe.starting
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=1 error='Get http://127.0.0.1:32770/: dial tcp 127.0.0.1:32770: connect: connection refused' time=2019-05-31T05:44:27Z
docker-slim[build]: state=processing
docker-slim[build]: state=building message='building minified image'
docker-slim[build]: info=http.probe.call status=error method=GET target=http://127.0.0.1:32770/ attempt=2 error='Get http://127.0.0.1:32770/: dial tcp 127.0.0.1:32770: connect: connection refused' time=2019-05-31T05:44:35Z
docker-slim[build]: state=completed
docker-slim[build]: info=results status='MINIFIED BY 3.48X [103166686 (103 MB) => 29652590 (30 MB)]'
docker-slim[build]: info=results  image.name=local/spring-boot.slim image.size='30 MB' data=true
docker-slim[build]: info=results  artifacts.location='/usr/local/bin/.docker-slim-state/images/8e5ccc8213f5fc3a3134dba8547b6dd543e7ae1ebad55084c334322efa919b15/artifacts'
docker-slim[build]: info=results  artifacts.report=creport.json
docker-slim[build]: info=results  artifacts.dockerfile.original=Dockerfile.fat
docker-slim[build]: info=results  artifacts.dockerfile.new=Dockerfile
docker-slim[build]: info=results  artifacts.seccomp=local-spring-boot-seccomp.json
docker-slim[build]: info=results  artifacts.apparmor=local-spring-boot-apparmor-profile
docker-slim[build]: state=done
(MoeLove) ➜  spring-boot-hello-world git:(master) ✗ 
(MoeLove) ➜  spring-boot-hello-world git:(master) ✗ docker image ls local/spring-boot.slim
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
local/spring-boot.slim   latest              92cc0239d51e        21 seconds ago      29.7MB
(MoeLove) ➜  spring-boot-hello-world git:(master) ✗ docker run -p 8080:8080 --rm local/spring-boot.slim 
Error occurred during initialization of VM
Unable to load ZIP library: /usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/libzip.so

I think it is missing the file libzip.so when compressing the image.

@kcq
Copy link
Member

kcq commented Jun 1, 2019

Thank you for the additional info! I have managed to repro the condition. It looks like it's OpenJDK and Alpine related.

I almost managed to make it work by including a few extra files minifying the image (using the --include-path parameter). Here's what my docker-slim build command looks like: docker-slim build --http-probe --include-path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/currency.data --include-path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/tzdb.dat --include-path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/rt.jar --include-path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/libzip.so my/java-spring-boot-hello-world. You can try it yourself if you are curious... Just replace my/java-spring-boot-hello-world with your image name. This minified container prints the Spring/Spring Boot logo failing trying the load the net library: java.lang.UnsatisfiedLinkError: no net in java.library.path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants