【问题标题】:mvn clean install -PbuildDocker don't workmvn clean install -PbuildDocker 不起作用
【发布时间】:2018-07-12 09:38:32
【问题描述】:

这是我的错误信息:

Step 9/10 : EXPOSE ${EXPOSED_PORT}
│[INFO] ------------------------------------------------------------------------
│[INFO] Reactor Summary:
│[INFO]
│[INFO] spring-petclinic-microservices ..................... SUCCESS [ 0.246 s]
│[INFO] spring-petclinic-admin-server ...................... FAILURE [ 10.753 s]
│[INFO] spring-petclinic-monitoring ........................ SKIPPED
│[INFO] spring-petclinic-customers-service ................. SKIPPED
│[INFO] spring-petclinic-vets-service ...................... SKIPPED
│[INFO] spring-petclinic-visits-service .................... SKIPPED
│[INFO] spring-petclinic-config-server ..................... SKIPPED
│[INFO] spring-petclinic-discovery-server .................. SKIPPED
│[INFO] spring-petclinic-api-gateway ....................... SKIPPED
│[INFO] spring-petclinic-tracing-server .................... SKIPPED
│[INFO] ------------------------------------------------------------------------
│[INFO] BUILD FAILURE
│[INFO] ------------------------------------------------------------------------
│[INFO] Total time: 11.951 s
│[INFO] Finished at: 2018-07-11T10:30:27+08:00
│[INFO] Final Memory: 75M/651M
│[INFO] ------------------------------------------------------------------------
│[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default) on project spri
│ng-petclinic-admin-server: Exception caught: EXPOSE requires at least one argument -> [Help 1]
│[ERROR]
│[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
│[ERROR] Re-run Maven using the -X switch to enable full debug logging.
│[ERROR]
│[ERROR] For more information about the errors and possible solutions, please read the following artic
│les:
│[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
│[ERROR]
│[ERROR] After correcting the problems, you can resume the build with the command
│[ERROR] mvn -rf :spring-petclinic-admin-server

似乎暴露需要一个参数。应该是什么?

这是 dockerfile。

我尝试将EXPOSE_PORT 设置为228899,但不起作用。 此错误信息:

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.13:build (default) on project spri
│ng-petclinic-admin-server: Exception caught: Request error: POST unix://localhost:80/build?buildargs=
│%7B%22ARTIFACT_NAME%22%3A%22spring-petclinic-admin-server-1.5.9%22%2C%22EXPOSED_PORT%22%3A%229090%22%
│7D&t=mszarlinski/spring-petclinic-admin-server: 500: HTTP 500 Internal Server Error -> [Help 1]
│[ERROR]

谢谢!

这是 pom.xml 中关于 admin-server 的插件:

<profiles>
    <profile>
        <id>buildDocker</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.spotify</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>${docker.plugin.version}</version>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

【问题讨论】:

  • 看起来像'EXPOSE 需要至少一个参数'。
  • 如果您的EXPOSE_PORT 是环境变量,则可能没有正确设置。
  • 你能分享你定义插件的 pom.xml 文件的 sn-p,如果可以分享的话。也在看这个插件,看来您使用的是非常旧的版本。最新的已经是 1.1.1 从这里 github.com/spotify/docker-maven-plugin 并且他们还建议使用其他插件 (github.com/spotify/dockerfile-maven) 而不是这个,因为它目前处于冻结状态,除了错误修复。

标签: java spring microservices


【解决方案1】:

你也可以使用Jib并设置

<configuration>
    <container>
        <ports>
            <port>xxxx</port>
        </ports>
    </container>
</configuration>

【讨论】:

    【解决方案2】:

    EXPOSE 指令通知 Docker 容器在运行时侦听指定的网络端口。可以指定端口监听 TCP 还是 UDP,如果不指定协议则默认为 TCP。

    EXPOSE &lt;port&gt; [&lt;port&gt;/&lt;protocol&gt;...]

    示例: EXPOSE 80/udp

    Refer this.

    还有see this.

    【讨论】:

      猜你喜欢
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 2013-05-12
      • 1970-01-01
      • 2018-10-08
      • 2014-03-30
      • 2021-04-23
      相关资源
      最近更新 更多