Docker image with Maven fails to run

I want to use Maven in my Docker image.

After looking here, I tried using this Dockerfile:

  • “docker-compose up” fails with error
  • Docker setup - facing issues while running chaincode locally
  • Forbid docker to use specific network
  • Modifying a docker image
  • How to use SERVICE_CHECK_HTTP with progrium/consul check-http script?
  • Docker on CentOS 7.2: kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1
  • FROM openjdk:7
    RUN apk add --no-cache curl tar bash
    ARG USER_HOME_DIR="/root"
    RUN mkdir -p /usr/share/maven /usr/share/maven/ref \
      && curl -fsSL$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
    COPY /usr/local/bin/
    COPY settings-docker.xml /usr/share/maven/ref/
    ENTRYPOINT ["/usr/local/bin/"]
    CMD ["mvn"]

    However, I’m getting:

    lstat no such file or directory

    I tried different Dockerfiles from the same repositories but they all throw this error.

    What’s wrong with this dockerfile?
    How can I use Maven with Docker?

  • How to upgrade elasticbeanstalk docker version
  • How to allocate more memory for docker container?
  • Docker run command failing when trying to install the mysql php extension
  • docker non-root bind-mount permissions, WITH --userns-remap
  • creating a default database in mysql using dockerfile
  • How to use docker to create a minimal live ISO that runs docker?
  • 3 Solutions collect form web for “Docker image with Maven fails to run”

    Try this:


    FROM openjdk:8u111-jdk-alpine
    COPY assets/settings.xml /tmp/settings.xml
    ENV PATH=$PATH:/opt/maven/bin
    RUN apk add --no-cache curl tar bash && \
      curl -SsL -o /tmp/maven.tar.gz && \
      mkdir -p /opt && \
      tar xzf /tmp/maven.tar.gz -C /opt/ && \
      ln -s /opt/apache-maven-3.3.9 /opt/maven && \
      rm /tmp/maven.tar.gz && \
      mv /tmp/settings.xml /opt/maven/conf/settings.xml

    You need to put this Dockerfile in a new directory, with a subdirectory called ‘assets’, and you need to put a maven settings file (settings.xml) in that directory. If you don’t have a custom settings file then remove the COPY and the mv.

    Build it with something like

    docker --tag ajava8 .

    You can run maven in your current directory using something like:

    docker run -it --rm -v /$PWD:/work -w /work ajava8 mvn clean install

    Or, you can get a bash shell with something similar, like this:

    docker run -it --rm -v /$PWD:/work -w /work ajava8 bash

    I just ran into the same problem, I have forgotten to download the “” file.. .. also the settings-docker.xml was required..

    You need the files copied in the Dockerfile and settings-docker.xml.
    You can git clone from

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.