title: How to run specific main class of a jar in docker and pass program argument
body: <p>I have a spring application with Java, i need to run specific main class of a jar with program argument i tried to search for a solution but could not find one
  i also need to pass program argument to the argsp[] in the main method of my class</p>
  <p><a href="https://stackoverflow.com/questions/15406532/how-to-run-a-specific-main-class-from-a-jar">this was similar but didn't help</a></p>
  <pre><code>CMD [&quot;java&quot;,&quot;-jar&quot;,&quot;/usr/local/jetty/myjar-0.0.1-SNAPSHOT.jar&quot;,&quot;com.company.migrate.db.build.MyMainClass&quot;,&quot;/var/lib/jetty/resources/&quot;]
  </code></pre>
  <p>but when I run my docker I get this error</p>
  <pre><code>no main manifest attribute, in /usr/local/jetty/myjar-0.0.1-SNAPSHOT.jar
  </code></pre>
  <p>I tried also this command</p>
  <pre><code>CMD [&quot;java&quot;,&quot;-jar&quot;,&quot;/usr/local/jetty/myjar-0.0.1-SNAPSHOT.jar&quot;,&quot;-Dexec.mainClass=com.company.migrate.db.build.MyMainClass&quot;,&quot;/var/lib/jetty/resources/&quot;]
  </code></pre>
  <p>Tried also running this command from the container</p>
  <pre><code>java -jar -Dloader.main=/usr/local/jetty/myjar-0.0.1-SNAPSHOT.jar com.company.migrate.db.build.MyMainClass 
  </code></pre>
  <p>But i get:</p>
  <pre><code>Error: Unable to access jarfile com.company.migrate.db.build.MyMainClass
  </code></pre>