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.

  • influxDB and cadvisor integration issue
  • (Windows Git-bash) IntelliJ git bash shell color scheme messed up with Docker
  • Which way to run PostgeSQL in Docker?
  • org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
  • How to get Clojure Compojure app to run headless via compiled jar within Docker container?
  • How to have docker and npm in gitlab-ci-runner-docker
  • Accessing logs folder of running docker container
  • How to ADD sibling directory to Docker image
  • Why doesn't Docker Toolbox work on Mac 10.10.5?
  • Deploying a Sails.js app to dokku-alt? Buildpack error
  • Unable to discover docker containers
  • How to do a custom deploy using ssh with Travis CI?
  • 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.