How to run a jar file using docker image?

My jar runs on a specific port and I am assuming there is port for the container so how I do run a jar using the docker image? how do these ports communicate with each other? Do I need to expose both of these ports? Do I need both Entrypoint and CMD? My jar file does need to accept any arguments since it can pick the defaults.

  • Monitor docker containers based on labels assigned
  • Docker client not able to connect to docker host on VM on Windows 7
  • has the linux kernel support sctp protocol in container of LXC/docker yet?
  • Multiple websites on one docker engine
  • Mongodb installation on Docker
  • pika.BlockingConnection() failing inside containers, works well within VMs
  • Tips on getting docker to work without having to run `sudo docker -d` on Ubuntu 15.04
  • Docker doesn't resolve hostname
  • add new GPG key detailed in Docker installation
  • REPOSITORY <none> TAG <none>
  • docker and image size limit
  • How can I use Kalabox with a WordPress Install that has a nested web root?
  • One Solution collect form web for “How to run a jar file using docker image?”

    If your container does not communicate with the external network (ie. the java program is the only one using those ports) then you do not need to expose the ports. Your entrypoint or cmd can be ~java -jar /my/jar and it will use your defaults.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.