How to containerize the spring boot application without installing docker and deploying in centos - spring-boot

I have a spring boot application in my local machine , i want to containerize it without installing docker in local machine and i want to deploy it in a Cent Os machine which docker has installed in an offline mode .
while i have tried to containerizing it by building an image file , it is actually looking for Docker Daemon in local and the build is getting failed.

Using GoogleContainerTools' Jib you can easily build a Docker compliant container image without Docker installed.
You need to install the Jib plugin in your pom.xml or gradle.build file.
Here is a simple example: https://www.baeldung.com/jib-dockerizing

Without Docker engine you cannot containerize the application, Docker daemon is needed for creating the container for your spring boot application in unix. You can use ECS on AWS that can create the container without docker but lot of configurations and deep knowledge is needed for that.

Related

Building a Docker Image with the Spring Boot Gradle Plugin and Colima

I'm trying to create a docker image of a Spring Boot application using the Gradle plugin. I'm using Spring Boot 2.6.4 and Gradle 7.1.1.
I'm on a Mac, and I don't have Docker Desktop installed. Indeed, I run docker using Colima.
The problem is that I cannot build the docker image with the command ./gradlew bootBuildImage since Gradle cannot find the docker daemon:
Connection to the Docker daemon at 'localhost' failed with error "[2] No such file or directory"; ensure the Docker daemon is running and accessible
Is there any configuration I have to do in Colima or my build.gradle file?
Colima creates a socket in the location ~/.colima/docker.sock by default. Running the command docker context ls should show a context named colima with the socket location shown in the DOCKER ENDPOINT column.
You can configure the Spring Boot Gradle plugin to use this socket by setting the DOCKER_HOST environment variable to unix:///Users/<user>/.colima/docker.sock or by adding the following to your build file as shown in the documentation.
tasks.named("bootBuildImage") {
docker {
host = "unix:///Users/<user>/.colima/docker.sock"
}
}

Spring Boot application logs with Docker Desktop

Environment:
Windows 10
Docker Desktop (2.0)
Running Linux Container of it. on my windows 10 machine.
I would like to store my spring boot app info logs on my C:\log folder.
how to write Volume in Dockerfile for this. So that my spring boot logs gets persisted at C:\log location.
I have created log4j2.json file for this which works perfectly on local ( without container)
Please suggest how to write
By default only C:/Users is shared with containers so your dockerfile volume should be something like this /c/Users/youruser/my_volume:/my_mnt

War deploying tomcat8

I have issue... I have spring-boot web application generated by jhipster. I need to deploy it with tomcat. Earlier I run it on virtual machine in home. Now I'm trying run it on OVH cloud. Everything is ok but when I type 'service tomcat8 start' and checking logs , I see that war is successfully deployed but it not run automatically after this operation. I was trying run it on windows and everything is okay. This same on virtual machine.. but on OVH always this same.
I deploy original file . I have java8 and tomcat8 on server. Maybe I forgot about some configurations in tomcat? It's fresh after install . Can anybody help?

spring boot takes like forever to start up in Openshift

I'm running a spring boot 1.4.3 app in openshift origin 1.3.
It takes more than 20 minutes to bring spring bootup.
the docker base container I'm using is alpine:3.4 with opendk8-jre.
the spring boot embedded container is using default tomcat one. I've installed the haveged and set -Djava.security.egd=file:/dev/./urandom
but if I run the image itself with docker run(I'm not using openshift), it can start up..
any idea why ?
Could it be the case that you don't have a maven proxy setup and are downloading all dependencies?
If it's the case your logs likely show that you are donwloading the same deps over and over.
run this command to see the logs:
oc logs _POD_NAME_
Also, have you tried the same in OpenShift Dev Preview and got similar results?

Is it possible to run kubernetes as a docker container?

I'm very new to kubernetes and trying to conceptualize it as well as set it up locally in order to try developing something on it.
There's a confound though that I am running on a windows machine.
Their "getting started" documentation in github says you have to run Linux to use kubernetes.
As docker runs on windows, I was wondering if it was possible to create a kubernetes instance as a container in windows docker and use it to manage the rest of the cluster in the same windows docker instance.
From reading the setup instructions, it seems like docker, kubernetes, and something called etcd all have to run "in parallel" on a single host operating system... But part of me thinks it might be possible to
Start docker, boot 'default' machine.
Create kubernetes container - configure to communicate with the existing docker 'default' machine
Use kubernetes to manage existing docker.
Pipe dream? Wrongheaded foolishness? I see there are some options around running it in a vagrant instance. Does that mean docker, etcd, & kubernetes together in a single VM (which in turn creates a cluster of virtual machines inside it?)
I feel like I need to draw a picture of what this all looks like in terms of physical hardware and "memory boxes" to really wrap my head around this.
With Windows, you need docker-machine and boot2docker VMs to run anything docker related.
There is no (not yet) "docker for Windows".
Note that issue 7428 mentioned "Can't run kubernetes within boot2docker".
So even when you follow instructions (from a default VM created with docker-machine), you might still get errors:
➜ workspace docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock gcr.io/google_containers/hyperkube:v0.14.2 /hyperkube kubelet --api_servers=http://localhost:8080 --v=2 --address=0.0.0.0 --enable_server --hostname_override=127.0.0.1 --config=/etc/kubernetes/manifests
ee0b490f74f6bc9b70c1336115487b38d124bdcebf09b248cec91832e0e9af1d
➜ workspace docker logs -f ee0b490f74f6bc9b70c1336115487b38d124bdcebf09b248cec91832e0e9af1d
W0428 09:09:41.479862 1 server.go:249] Could not load kubernetes auth path: stat : no such file or directory. Continuing with defaults.
I0428 09:09:41.479989 1 server.go:168] Using root directory: /var/lib/kubelet
The alternative would be to try on a full-fledge Linux VM (like the latest Ubuntu), instead of a boot2docker-like VM (based on a TinyCore distro).
All k8s components can be raised up with hyperkube, which helps you bring up a containerized one.
If you're able to run docker on windows, it would probably work. I haven't tried it on windows personally.

Resources