spring-boot構(gòu)建docker鏡像上傳倉(cāng)庫的示例教程
spring-boot構(gòu)建docker鏡像上傳倉(cāng)庫
創(chuàng)建一個(gè)簡(jiǎn)單spring-boot-web項(xiàng)目
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
</parent>
<groupId>com.example</groupId>
<artifactId>spring-boot-docker-demo</artifactId>
<version>1.0.0</version>
<properties>
<jave.version>1.8</jave.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.8.0</version>
<configuration>
<from>
<!-- 拉取基礎(chǔ)鏡像 -->
<image>openjdk:8-jdk-alpine</image>
</from>
<to>
<!-- 格式:官方docker hub->用戶名/鏡像名 -->
<!-- 格式:阿里云容器鏡像服務(wù)->registry.cn-hangzhou.aliyuncs.com/服務(wù)空間/鏡像名 -->
<image>registry.cn-hangzhou.aliyuncs.com/服務(wù)空間/${project.name}</image>
<!-- 鏡像版本號(hào) -->
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
<auth>
<username>用戶名</username>
<password>密碼</password>
</auth>
</to>
<container>
<!-- 啟動(dòng)類 -->
<mainClass>啟動(dòng)類地址</mainClass>
<useCurrentTimestamp>use</useCurrentTimestamp>
<!-- 服務(wù)暴露的端口 -->
<ports>
<port>8080</port>
</ports>
</container>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
準(zhǔn)備工作
- 創(chuàng)建docker倉(cāng)庫鏡像工程
- 配置docker hub push參數(shù)
執(zhí)行

查看鏡像上傳倉(cāng)庫
思考
這時(shí)候我們發(fā)現(xiàn)當(dāng)前倉(cāng)庫信息明文暴露在項(xiàng)目中,這時(shí)候又要怎么處理,讓其提高安全性。
方案1
mvn compile com.google.cloud.tools:jib-maven-plugin:1.8.0:build -Djib.to.auth.username=user -Djib.to.auth.password=pass -Dimage=<MY IMAGE>
方案2
使用maven設(shè)置,只在本地可用
<settings>
...
<servers>
...
<server>
<id>MY_REGISTRY</id>
<username>MY_USERNAME</username>
<password>{MY_SECRET}</password>
</server>
</servers>
</settings>到此這篇關(guān)于spring-boot構(gòu)建docker鏡像上傳倉(cāng)庫的文章就介紹到這了,更多相關(guān)docker鏡像上傳倉(cāng)庫內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- docker-maven-plugin打包鏡像并上傳到私有倉(cāng)庫
- Spring Boot 打包上傳Docker 倉(cāng)庫的詳細(xì)步驟
- Docker上傳鏡像至私有倉(cāng)庫的方法示例
- SpringBoot打包docker鏡像發(fā)布的詳細(xì)步驟
- IDEA2021.2配置docker如何將springboot項(xiàng)目打成鏡像一鍵發(fā)布部署
- docker-compose鏡像發(fā)布springboot項(xiàng)目的流程分析
- Docker?快速部署Springboot項(xiàng)目超詳細(xì)最新版
- springboot docker jenkins 自動(dòng)化部署并上傳鏡像的步驟詳解
- Docker 部署 SpringBoot 項(xiàng)目整合 Redis 鏡像做訪問計(jì)數(shù)示例代碼
相關(guān)文章
docker啟動(dòng)報(bào)錯(cuò)問題OCI runtime create failed: c
這篇文章主要介紹了docker啟動(dòng)報(bào)錯(cuò)問題OCI runtime create failed: container_linux.go:380: starting container process,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-08-08
解決Docker啟動(dòng)Elasticsearch7.x報(bào)錯(cuò)的問題
這篇文章主要介紹了解決Docker啟動(dòng)Elasticsearch7.x報(bào)錯(cuò)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-11-11
Docker使用編寫dockerfile啟動(dòng)node.js應(yīng)用
這篇文章主要介紹了Docker使用編寫dockerfile啟動(dòng)node.js應(yīng)用,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-01-01
docker 使用mysqldump命令備份導(dǎo)出項(xiàng)目中的mysql數(shù)據(jù)
這篇文章主要介紹了docker 使用mysqldump命令備份導(dǎo)出項(xiàng)目中的mysql數(shù)據(jù)本文通過命令給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12

