Search code examples
dockercmdjarcommit

Error in --commit CMD Change in Docker via command line


enter image description here

I am trying to put a spring boot java .jar file into an Image off openJDK and commit the change to it in docker but docker command does not seem to work

I am following this article for steps : https://dzone.com/articles/docker-tutorial-for-beginners-with-java-and-spring

What argument is docker expecting which , I did not give in the command

docker container commit --change='CMD ["java","-jar","/tmp/mytroubleartifact-0.jar"]' upbeat_brahmagupta a-repo-name-of-choice/some-app-name:tagname2

Solution

  • the issue is with the apostrophe ' you should be using apostrophes (in plural - otherwise known as quotation marks) "

    This command seems to be working for me

    (no changes needed on your behalf):

    docker container commit --change="CMD ['java','-jar','/tmp/mytroubleartifact-0.jar']" upbeat_brahmagupta a-repo-name-of-choice/some-app-name:tagname2

    though I've seen other people using a single apostrophe for me it also didn't work with your situation. docker docs example also didnt work with just copying the --change part, with both options (-c, --change) and with just one of them, only using double qoutes did the trick, not exactly sure why though. (tried replacing names, making them shorter ¯_(ツ)_/¯)

    docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a svendowideit/testimage:version4

    enter image description here

    thanks to these posts for the working example:

    https://adamtheautomator.com/docker-commit/ https://docs.oracle.com/cd/E37670_01/E75728/html/ch04s18.html