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

查看:2518
本文介绍了基于"openjdk:8-jdk-alpine"构建docker映像时,无法运行"./mvnw全新安装".用于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

进行了一些研究后,我仍然没有找到解决方案. 我的泊坞窗版本 Windows10专业版上的Docker version 18.06.1-ce, build 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全新安装".用于Spring Boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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