--https://share.google/aimode/C9Ncgh6YM4dFfs5Tt
Refer this blog to know how to create kubernetes master node & worker node
https://trythissolution.blogspot.com/2026/07/create-k8s-master-worker-node.html
To run a Spring Boot application directly in containerd without relying on Docker Desktop or the standard Docker CLI, you must use
nerdctl (a Docker-compatible CLI for containerd) or ctr (the native, low-level containerd CLI). [1, 2, 3, 4]Because
ctr is designed solely for low-level debugging and cannot easily handle publishing ports, using nerdctl is the highly recommended approach for local development and testing. [1]Step 1: Build the Spring Boot Image
1. Create a
Dockerfile in your project root: [1]dockerfile
FROM eclipse-temurin:17-jre-alpine
WORKDIR /app
COPY target/*.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
bash
# Build the JAR file
mvn clean package
# Build the OCI container image directly into containerd
sudo nerdctl build -t spring-boot-app:latest .
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
Step 2: Run the Container
nerdctl features a command syntax identical to Docker, allowing you to expose network ports seamlessly. [1]Run the image using the following command:
bash
sudo nerdctl run -d --name my-spring-app -p 8080:8080 spring-boot-app:latest
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
- Use
sudo nerdctl psto view your running container. - Access your application at
http://localhost:8080. [1]
1. Import your image into the default containerd namespace:
If you built your image with Docker instead of
If you built your image with Docker instead of
nerdctl, export it as a tarball and load it into ctr:bash
docker save spring-boot-app:latest -o spring-app.tar
sudo ctr images import spring-app.tar
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
2. Run the container with host networking: [1]
bash
sudo ctr run --net-host --detached docker.io/library/spring-boot-app:latest my-spring-app
குறியீட்டைக் கவனமாகப் பயன்படுத்துங்கள்.
- Note: Ensure your
application.propertiesdoes not conflict with any existing services running on port 8080 on your host machine.
Step 3: Verify the Running Application
You can check the container startup logs to ensure your Spring Boot banner loads successfully: [1]
- For nerdctl:
sudo nerdctl logs my-spring-app - For ctr:
sudo ctr tasks logs my-spring-app
If you plan to scale this implementation, let me know:
- Will you be orchestration-managing this application via Kubernetes (K8s) or K3s?
- Do you require a multistage build configuration to reduce overall container size?
- Do you need assistance setting up health checks or environment variables?
No comments:
Post a Comment