Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install a custom image on Docker on Kubernates

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install a custom image on Docker on Kubernates". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to install custom images on Docker on Kubernates".

1. Create a springboot application, such as helloworld, and package it as a jar file

two。 Create a Dockerfile image build file

FROM frolvlad/alpine-oraclejdk8:slimMAINTAINER "xxx" LABEL description= "Spring Boot Image As Helloworld" WORKDIR / appVOLUME / tmpENV LANG en_US.UTF-8RUN ln-sf / usr/share/zoneinfo/Asia/Shanghai / etc/localtimeCMD locale & & dateCOPY helloworld-0.0.1-SNAPSHOT.jar helloworld.jarRUN sh-c 'touch / helloworld.jar'ENV JAVA_OPTS= "EXPOSE 8080ENTRYPOINT [" sh ","-c "," java $JAVA_OPTS-jar helloworld.jar "]

3. Upload the Dockerfile file and jar package to the server in the same folder

4. Execute build statement

Docker build-t springboot-helloworld:latest.

5. Tag and push to the local image

Docker tag springboot-helloworld 192.168.1.2:5000/springboot-helloworld:latest

6. Create a resource springboot-helloworld-rc.yaml file

ApiVersion: v1kind: ReplicationControllermetadata: name: springboot-helloworld labels: name: springboot-helloworldspec: replicas: 3 selector: name: springboot-helloworld template: metadata: labels: name: springboot-helloworldspec: containers:-name: springboot-helloworld image: 192.168.1.2:5000/springboot-helloworld:latest ports:-containerPort: 8080

7. Create a service springboot-helloworld-svc.yaml file

ApiVersion: v1kind: Servicemetadata: name: springboot-helloworld labels: name: springboot-helloworldspec: type: NodePort ports:-port: 8080 nodePort: 28080 selector: name: springboot-helloworld

8. Create resources through the Kubernates container web ui interface-rc

9. Create a service through the Kubernates container web ui interface-svc

10. Access the helloworld service

Http://192.168.1.0:28080

At this point, I believe you have a deeper understanding of "how to install custom images on Docker on Kubernates". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report