1 、maven 中配置的
<properties>
<dockerfile-maven-plugin-version>1.3.6</dockerfile-maven-plugin-version>
<!--docker插件-->
<image.tag.verion>v1.0.0</image.tag.verion>
<!-- Harbor对应的ip和port -->
<docker.repostory>x.x.x.x:9980</docker.repostory>
<!--项目名,需要和Harbor中的项目名称保持一致 -->
<docker.registry.name>test</docker.registry.name>
</properties>
<!--配置maven仓库结束 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<!-- 和maven setting中的配置的serverid 一致,根据这个去找harbor地址 -->
<serverId>docker-harbor</serverId>
<registryUrl>http://${docker.repostory}</registryUrl>
<!--必须配置dockerHost标签(除非配置系统环境变量DOCKER_HOST)-->
<dockerHost>http://x.x.x.x:2375</dockerHost>
<!-- imageName 必须这么设置,可以改tag,不然没push 到harbor -->
<imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}:${image.tag.verion}
</imageName>
<forceTags>true</forceTags>
<!-- 指定 Dockerfile 路径-->
<dockerDirectory>${basedir}</dockerDirectory>
<!-- jar包位置-->
<resources>
<resource>
<targetPath>/</targetPath>
<!-- target目录下-->
<directory>${project.build.directory}</directory>
<!--通过jar包名找到jar包-->
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
2、maven setting中的配置
<servers>
<server>
<id>docker-harbor</id>
<username>admin</username>
<password>Harbor12345</password>
</server>
</servers>
3、Dockerfile docker 中必须存在From 的基础镜像 或者 dockerhub可以找到基础镜像
FROM openjdk:8
Dockerfile参考博文
https://blog.csdn.net/qq_54729417/article/details/127913536
4、docker 配置 harbor 地址 在 /etc/docker/daemon.json 中添加 insecure-registries,
{
"registry-mirrors": ["https://l040g3fw.mirror.aliyuncs.com"],
"insecure-registries": ["x.x.x.x:9980"]
}
加载文件,重启docker
systemctl daemon-reload
systemctl restart docker
4、推送 镜像到harbor 两种方式
方式一
docker 推送镜像 build 构建镜像到docker ,push 镜像到harbor
方式二 利用ideal docker 插件 推送到harbor
ideaJ 还用方式一种的方式构建镜像。然后 service 选项卡,连接docker 后选择 docker 后 选择某个image,push镜像
ideal 配置harbor 地址
push 镜像时 填写
harbor 登录时 账号密码错误
参考 https://blog.csdn.net/DDJ_TEST/article/details/125151743
一些 postgresql 命令
查看所有库;
SELECT datname FROM pg_database;
切换到registry库;(注意 有\)
\c registry;