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:
- Clone the repository
git clone
- 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)
- Check docker-images
docker images
- Run the docker image
docker run java_helloworld
Push docker image to docker hub
- Log in to Docker Hub. Enter your password when prompted
docker login --username=yourusername --email=youremail@company.com
- Tag your image
docker tag java_helloworld yourusername/java_helloworld:latest
- 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