Reputation:
When I try to build this Docker-Image, I get the following error:
FROM java:8
WORKDIR /app
ADD . /app
EXPOSE 8080
RUN ./gradlew build
CMD ./gradlew bootRun
When I just build the app with "gradlew build" it runs and when I try to run this Docker Image with a Mac, it works too, just not for windows
EDIT:
Upvotes: 1
Views: 2346
Reputation: 37
Worked for me, adding in the dockerfile, before RUN ./gradlew lib:build
:
RUN apt-get update && \
apt-get install dos2unix && \
apt-get clean
RUN dos2unix gradlew
RUN chmod +x gradlew
RUN ./gradlew lib:build
Upvotes: 0
Reputation: 396
This is not a great answer, but what I found is that when Windows mounts files into Docker from Windows, it leaves Windows-like line endings on the mounted files. A janky way to solve it in your Dockerfile would be to install dos2unix in the container and add a
RUN dos2unix gradlew
prior to executing your build process. Unfortunately, this is a TERRIBLE solution. Hopefully Docker for Windows on WSL2 that is supposed to release soon will solve this better but for now you are stuck with this janky solution.
Upvotes: 1
Reputation: 4289
gradlew must be marked as executable.
chmod +x gradlew
Mac and Linux share permissions scheme but Windows needs to use a virtual FS so it copies files with default permissions - 644 and you need 755.
Upvotes: 0