新聞中心
本篇內(nèi)容主要講解“Kubernates上Docker怎么安裝自定義鏡像”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“Kubernates上Docker怎么安裝自定義鏡像”吧!
成都創(chuàng)新互聯(lián)公司是工信部頒發(fā)資質(zhì)IDC服務(wù)器商,為用戶提供優(yōu)質(zhì)的服務(wù)器托管服務(wù)
1.創(chuàng)建springboot應(yīng)用,比如helloworld,并打包為jar文件
2.創(chuàng)建Dockerfile鏡像構(gòu)建文件
FROM frolvlad/alpine-oraclejdk8:slim MAINTAINER "xxx" LABEL description="Spring Boot Image As Helloworld" WORKDIR /app VOLUME /tmp ENV LANG en_US.UTF-8 RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime CMD locale && date COPY helloworld-0.0.1-SNAPSHOT.jar helloworld.jar RUN sh -c 'touch /helloworld.jar' ENV JAVA_OPTS="" EXPOSE 8080 ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar helloworld.jar" ]
3.上傳Dockerfile文件和jar包到服務(wù)器同一文件夾下
4.執(zhí)行構(gòu)建語(yǔ)句
docker build -t springboot-helloworld:latest .
5.打標(biāo)簽,并push到本地鏡像中
docker tag springboot-helloworld 192.168.1.2:5000/springboot-helloworld:latest
6.創(chuàng)建資源springboot-helloworld-rc.yaml文件
apiVersion: v1 kind: ReplicationController metadata: name: springboot-helloworld labels: name: springboot-helloworld spec: replicas: 3 selector: name: springboot-helloworld template: metadata: labels: name: springboot-helloworld spec: containers: - name: springboot-helloworld image: 192.168.1.2:5000/springboot-helloworld:latest ports: - containerPort: 8080
7.創(chuàng)建服務(wù)springboot-helloworld-svc.yaml文件
apiVersion: v1 kind: Service metadata: name: springboot-helloworld labels: name: springboot-helloworld spec: type: NodePort ports: - port: 8080 nodePort: 28080 selector: name: springboot-helloworld
8.通過(guò)Kubernates容器web ui界面進(jìn)行創(chuàng)建資源-rc
9.通過(guò)Kubernates容器web ui界面進(jìn)行創(chuàng)建服務(wù)-svc
10.訪問(wèn)helloworld服務(wù)
http://192.168.1.0:28080
到此,相信大家對(duì)“Kubernates上Docker怎么安裝自定義鏡像”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
本文標(biāo)題:Kubernates上Docker怎么安裝自定義鏡像
URL地址:http://m.biofuelwatch.net/article/popejg.html