Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to install a custom image on Docker on Kubernates

Shulou Source: shulou.com Published: 2022-06-01 12:49:32 09月18日 Update

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!

Tags: Files images services content containers interfaces resources learning utility deeper interest practicality practical easy to operate folders methods more friends servers tags Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info NVidia Shulou Technology Redmi