jib
插件打包,详情可以参考这篇文章:Spring Boot:使用maven的jib插件打docker使用所需的镜像包docker
镜像,无法使用ping
命令,报错,找不到这个命令bash: ping:command not found
eclipse-temurin:11-jre-focal
,这个版本里的ubuntu
没有安装不需要的命令eclipse-temurin:11-jre-focal
镜像,使用docker-compose.yml
创建容器启动失败Starting jre-focal ... done
Attaching to jre-focal
jre-focal exited with code 0
docker-compose
配置为: jre-focal:
image: eclipse-temurin-cy:11-jre-focal
container_name: jre-focal
docekr ps -a
看到服务状态STATUS
为Exited (0)
。因为只是创建了容器,不在运行状态docker-compose
启动,可以使用原始docker
命令docker run
以交互方式启动镜像docker run -it eclipse-temurin:11-jre-focal /bin/bash
,启动成功,可以在容器中安装软件了。-it
表示交互方式,/bin/bash
为指定启动的终端apt-get update -y && apt-get -y install iputils-ping
docker commit
导出为镜像了docker login -u 用户名
,输入密码,登录docker commit ID名 用户名/仓库名
推送到docker hub <jib-maven-plugin.image>1363241277/jre11:11-jre-focal</jib-maven-plugin.image>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven-plugin.version}</version>
<configuration>
<from>
<image>${jib-maven-plugin.image}</image>
<platforms>
<platform>
<architecture>${jib-maven-plugin.architecture}</architecture>
<os>linux</os>
</platform>
</platforms>
</from>
<to>
<image>unit:latest</image>
</to>
<container>
<entrypoint>
<shell>bash</shell>
<option>-c</option>
<arg>/entrypoint.sh</arg>
</entrypoint>
<ports>
<port>8181</port>
<port>5701/udp</port>
</ports>
<environment>
<SPRING_OUTPUT_ANSI_ENABLED>ALWAYS</SPRING_OUTPUT_ANSI_ENABLED>
<JHIPSTER_SLEEP>0</JHIPSTER_SLEEP>
</environment>
<creationTime>USE_CURRENT_TIMESTAMP</creationTime>
<user>1000</user>
</container>
<extraDirectories>
<paths>src/main/docker/jib</paths>
<permissions>
<permission>
<file>/entrypoint.sh</file>
<mode>755</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
</plugin>