4.0.0
org.springframework.boot
spring-boot-starter-parent
2.6.3
com.csdn
blog
blog
Demo project for Spring Boot
1.0.0-RELEASE
1.8
192.168.10.194:2375
org.springframework.boot
spring-boot-starter-web
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
blog-${dadao.version}
org.springframework.boot
spring-boot-maven-plugin
paketobuildpacks/builder-jammy-base:latest
org.projectlombok
lombok
com.spotify
docker-maven-plugin
1.2.2
build-image
package
${docker.host}
${project.artifactId}
${project.version}
${project.basedir}
["java","-Xmx512m", "-Xms256m", "-jar","/${project.build.finalName}.jar","--spring.profiles.active=${profiles.active}"]
/
${project.build.directory}
${project.build.finalName}.jar
Name:自定义
Dockerfile:选择上一步创建的Dockerfile文件
ImageTag:镜像标签自定义
ContainerName:容器名称自定义
BindPort:前一个是服务器对外暴露端口(访问服务使用),后一个是容器端口
Run built image:上传到docker并运行
maven package:进行打包
run:进行推送
登录私有仓库
docker login -u admin -p harbor密码 192.168.10.194:9526
将镜像进行标记
# docker tag 镜像名称:镜像版本 harbor服务器IP:harbor服务器端口/harbor中创建的项目/上传到harbor中镜像名称:上传到harbor中镜像版本
docker tag blog:latest 192.168.10.194:9526/public/blog:latest
上传镜像
docker push 192.168.10.194:9526/public/blog:latest
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.6.3
com.csdn
blog
blog
Demo project for Spring Boot
1.0.0-RELEASE
1.8
public
192.168.10.194:2375
192.168.10.194:9526
org.springframework.boot
spring-boot-starter-web
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
blog-${dadao.version}
org.springframework.boot
spring-boot-maven-plugin
paketobuildpacks/builder-jammy-base:latest
org.projectlombok
lombok
com.spotify
dockerfile-maven-plugin
1.4.13
build-image
package
build
push
false
${project.basedir}
true
${harbor.host}/${harbor.namespace}/${project.artifactId}
${project.version}
target/${project.build.finalName}.jar
【重启电脑】:添加完环境变量之后需要重启电脑(重启Idea不生效)
错误一:未添加环境变量
信息: I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://localhost:80: \\.\pipe\docker_engine (系统找不到指定的文件。)
错误二:添加环境变量但环境变量中DOCKER_HOST给了错误地址
Caused by: com.spotify.docker.client.exceptions.DockerRequestException: Request error: GET http://192.168.10.194:9526/version: 200
在Maven配置文件中servers节点下添加harbor服务器配置
192.168.10.194:9526
admin
您的harbor服务器密码
[email protected]
错误一:未在maven配置文件中配置harbor服务器信息
unauthorized: unauthorized to access repository: public/blog, action: push: unauthorized to access repository: public/blog, action: push
IDEA中运行Maven package进行打包推送至Harbor