Idea配置docker

1、Idea安装Docker插件

 

2、配置Docker

docker开启远程连接:地址

 3、修改POM文件

新增如下代码:

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>1.4.13</version>
    <configuration>
         <repository>${project.artifactId}</repository>
         <buildArgs>
             <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
         </buildArgs>
    </configuration>
</plugin>    

4、新建Dockerfile

在项目根目录下创建Dockerfile

Dockerfile配置如下:

FROM openjdk:8-jdk-alpine

ENV LANG en_US.UTF-8

# Add the service itself
ARG JAR_FILE=target/*.jar

COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java", "-jar", "/app.jar"]

5、新增Run/Debug Configrations

6、运行

7、常见问题

问题1:no main manifest attribute, in /app.jar

解决方案:POM如下配置:

<plugin>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <version>${spring-boot.version}</version>
   <configuration>
      #报 no main manifest attribute错误,注释skip,新增includeSystemScope
    <mainClass>com.example.arthasdemo.ArthasDemoApplication</mainClass>
    <!--<skip>true</skip>-->
       <includeSystemScope>true</includeSystemScope>
   </configuration>
   <executions>
       <execution>
           <id>repackage</id>
           <goals>
                <goal>repackage</goal>
           </goals>
       </execution>
   </executions>
</plugin>    

 问题2:在docker容器中运行arthas报错:Unable to get pid of LinuxThreads manager thread

解决方案:Run/Debug Configurations新增 “--init”

 

posted @ 2023-11-28 14:32  SuperShen  阅读(1444)  评论(0编辑  收藏  举报