问题描述
我想在我的 Docker 镜像中使用 Maven.
I want to use Maven in my Docker image.
查看这里后https://hub.docker.com/_/maven/,我尝试使用这个 Dockerfile:
After looking here https://hub.docker.com/_/maven/, I tried using this Dockerfile:
FROM openjdk:7
RUN apk add --no-cache curl tar bash
ARG MAVEN_VERSION=3.3.9
ARG USER_HOME_DIR="/root"
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
&& curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
| tar -xzC /usr/share/maven --strip-components=1 \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
ENV MAVEN_HOME /usr/share/maven
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
COPY mvn-entrypoint.sh /usr/local/bin/mvn-entrypoint.sh
COPY settings-docker.xml /usr/share/maven/ref/
VOLUME "$USER_HOME_DIR/.m2"
ENTRYPOINT ["/usr/local/bin/mvn-entrypoint.sh"]
CMD ["mvn"]
但是,我得到:
lstat mvn-entrypoint.sh: no such file or directory
我尝试了来自同一个存储库的不同 Dockerfile,但它们都抛出了这个错误.
I tried different Dockerfiles from the same repositories but they all throw this error.
这个 dockerfile 有什么问题?如何在 Docker 中使用 Maven?
What's wrong with this dockerfile?How can I use Maven with Docker?
推荐答案
我刚遇到同样的问题,我忘记下载 "mvn-entrypoint.sh" 文件.. https://github.com/carlossg/docker-maven/tree/322d031bdff4df322d07bdff4df320dfc8c8fc8dfc8df3df320dfc8c8dfc8dfc8d.. 还需要 settings-docker.xml ..
I just ran into the same problem, I have forgotten to download the "mvn-entrypoint.sh" file.. https://github.com/carlossg/docker-maven/tree/322d0dff5d0531ccaf47bf49338cb3e294fd66c8/jdk-8 .. also the settings-docker.xml was required..
这篇关于使用 Maven 的 Docker 映像无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!