Search code examples
javadockergradledockerfilegradlew

Unable to Build Docker Image with gradlew Command


I am trying to build docker image having following command in Dockerfile

FROM openjdk:13-jdk-alpine AS builder
WORKDIR /app-build
ADD . .
RUN pwd
RUN ./gradlew console:build
RUN ls /app-build/console/build/libs/

It exit with following message

/bin/sh: ./gradlew: not found
The command '/bin/sh -c ./gradlew console:build' returned a non-zero code: 127 

Solution

  • you need to place your local directory path where your docker file is located and the path of your code repo in docker build command docker build -f /home/ubuntu/your_project_repo/Dockerfile /home/ubuntu/your_project_repo/