/Docker-Kubernetes-jar-file

Create Docker image of a java jar file and manage the container using Kubernetes | Docker | Kubernetes | Jar | Pods

Primary LanguageJavaMIT LicenseMIT

Docker-Kubernetes-jar-file

Create Docker image of a java jar file and manage the container image using Kubernetes

  • Docker is a open source tool.
  • It is designed to makes it easier to create, deploy and run applications by using containers.
  • Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package, called image.
  • It ensures that the application will run the same no matter which server or laptop its running on.
  • This way, it eliminates the “it works on my machine” problem.
  • Developers will not spend time in setting up environments or debugging environment-specific issues.
  • Ensures consistent environments from development to production.
  • It is an open source container orchestration tool.
  • It is used to automate deployments, scaling, and operations of application containers across clusters of hosts
  • Kubernetes is capable of doing auto-placement, auto-restart, auto-replication and auto-healing of containers extremely well.

Create docker image of a runnable jar file:

  1. Clone the repository
git clone 
  1. Open command prompt or powershell and build the dockerfile
docker build -t java_helloworld .

(Note: Don't forget to put dot (.) at the end of the command)

  1. Check docker-images
docker images

  1. Run the docker image
docker run java_helloworld


Push docker image to docker hub

  1. Log in to Docker Hub. Enter your password when prompted
docker login --username=yourusername --email=youremail@company.com
  1. Tag your image
docker tag java_helloworld yourusername/java_helloworld:latest
  1. Push your image to docker hub repository
docker push yourusername/java_helloworld

Manage image container using Kubernetes

Create container by running yaml file

kubectl apply -f java_helloworld.yaml