Home > Blockchain >  unable to start container process: exec: "mvnw": executable file not found in $PATH: unkno
unable to start container process: exec: "mvnw": executable file not found in $PATH: unkno

Time:07-16

This is my source code https://github.com/donhuvy/springboot-docker . I follow guide at tutorial video https://www.youtube.com/watch?v=7BCtc9cAS6o . File Dockerfile

# syntax=docker/dockerfile:1
#Which "official Java image" ?
FROM openjdk:oraclelinux8
#working directory
WORKDIR /app
#copy from your Host(PC, laptop) to container
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
#Run this inside the image
RUN ./mvnw dependency:go-offline
COPY src ./src
#run inside container
CMD [ "mvnw", "spring-boot:run" ]

Log

C:\Users\donhu>docker pull donhuvy/springboot-docker:v1.0.0
v1.0.0: Pulling from donhuvy/springboot-docker
e54b73e95ef3: Pull complete
e6e62647f09f: Pull complete
da8e06a8884e: Pull complete
d8cbf9b4e6de: Pull complete
9971eb650313: Pull complete
366b24bf882f: Pull complete
35b5c085babf: Pull complete
b51a76bbfa65: Pull complete
Digest: sha256:f637c16c3b2a930d048e95f89f2a7aa53754f349e08e0c5a86398c5481eb07f1
Status: Downloaded newer image for donhuvy/springboot-docker:v1.0.0
docker.io/donhuvy/springboot-docker:v1.0.0

C:\Users\donhu>docker run donhuvy/springboot-docker:v1.0.0
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "mvnw": executable file not found in $PATH: unknown.

C:\Users\donhu>

How to fix it?

CodePudding user response:

add springboot-docker dir to your $PATH variable.

basically the shell is not able to find the mvnw command, it looks for all the locations in the $PATH var. since your mvnw binary is located in your project dir you need to add it.

if this was in a linux environment it would be done like this export PATH=$PATH:./springboot-docker

for windows you can search online how this can be edited.

CodePudding user response:

Change CMD [ "mvnw", "spring-boot:run" ] to CMD [ "./mvnw", "spring-boot:run" ]

When your docker want to execute command mvnw springboot:run, it needs to find file mvnw in environment $PATH, but find none.

Change mvnw to ./mvnw which will tell docker to execute the mvnw file in current work directory(where you have copied mvnw before).

  • Related