'Unable to commit a container in Docker with Jar file
I have a created a Jar file using spring boot project and the container name is clever_bohr
and i want to commit the container using the --change='CMD ["java","-jar","/tmp/hello-world-rest-api.jar"]'
However it's throwing error as below
C:\Development\Docker\docker-crash-course-master\01-hello-world-rest-api>docker commit --change='CMD ["java","-jar","/tmp/hello-world-rest-api.jar"]' clever_bohr clever_bohr2:latest
"docker commit" requires at least 1 and at most 2 arguments.
See 'docker commit --help'.
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Create a new image from a container's changes
However when i remove the --change
command , it's working fine. I have verified and the jar file is present in tmp directory as below
C:\Development\Docker\docker-crash-course-master\01-hello-world-rest-api>docker container exec clever_bohr ls /tmp
hello-world-rest-api.jar
Solution 1:[1]
If you are using windows, it could be the problem because of single quotes in command line.
Try the below option for windows:
docker commit --change="CMD ("java" "-jar" "/tmp/hello-world-rest-api.jar")" clever_bohr clever_bohr2:latest
Solution 2:[2]
Maybe Java path wasn't set. Try using "/usr/bin/java" instead of Java.
Or maybe your double quotes character is not " rather something similar looking.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | fcdt |
Solution 2 | Jarri Abidi |