基于“openjdk:8-jdk-alpine"构建 docker 映像时无法运行“./mvnw clean install"对于 Spring Boot 应用程序 [英] Unable to run './mvnw clean install' when building docker image based on "openjdk:8-jdk-alpine" for Spring Boot app

查看:40
本文介绍了基于“openjdk:8-jdk-alpine"构建 docker 映像时无法运行“./mvnw clean install"对于 Spring Boot 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 docker 容器中使用 spring.io.starter 提供的 maven 包装器构建一个 Spring Boot 应用程序.我的 Dockerfile 是:

I would like to build a Spring Boot app using the maven wrapper provided by spring.io.starter inside a docker container. My Dockerfile is:

FROM openjdk:8-jdk-alpine
# install bash --> commented because I just need /bin/sh which is already provided by the base image
#RUN apk add --no-cache bash
ENV APP_DIR /app
ENV APP app.jar
WORKDIR ${APP_DIR}
COPY . ${APP_DIR}
# ===> HERE THE PROBLEM
RUN /bin/sh -c "./mvnw clean install"
ENTRYPOINT ["java","-jar","chicowa-app.jar"]
EXPOSE 8080

我有这个错误:

/bin/sh: ./mvnw: not found

经过一些研究,我仍然没有找到解决方案.我的码头工人版本Docker 版本 18.06.1-ce,在 Windows10 pro 上构建 e68fc7a

After making some researches I still don't find a solution. My docker version Docker version 18.06.1-ce, build e68fc7a on Windows10 pro

非常感谢您的帮助.

解决方案是直接使用 RUN apk add --no-cache maven 安装 maven,但我想尽可能减小图像的大小.

A solution would be to install maven directly with a RUN apk add --no-cache maven but I would like to minimize as possible the image' size.

推荐答案

我们只在 Windows 10 上试验了这个问题,并且仅仅应用了 dos2unix 就能够解决这个问题

We were experimenting this issue only on Windows 10 and were able to solve this issue on just applying dos2unix

dos2unix mvnw

这篇关于基于“openjdk:8-jdk-alpine"构建 docker 映像时无法运行“./mvnw clean install"对于 Spring Boot 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆