'Error /bin/sh: ./pipeline.sh: not found powershell v.7
I am attempting run a docker image using Powershell v.7. Both files exist in the same folder but I receive the following message:
docker container run --rm --name builder -v /var/run/docker.sock:/var/run/docker.sock -v /c/users/tab45/fod/ch08/sample-app:/usr/src/app -e HUB_USER=<> -e HUB_PWD=<>@j -e repository=ch08-sample-app -e TAG=1.0 builder
**/bin/sh: ./pipeline.sh: not found**
Pipeline .sh file:
#!/bin/bash
#***Sample Script to build, test and push containerized Node.js applications ***
#build docker image
docker image build -t $HUB_USER/$REPOSITORY:$TAG .
#Run all unit tests
docker container Run $HUB_USER/$REPOSITORY:$TAG npm test
#Login to docker Hub
docker Login -u $HUB_USER -p $HUB_PWD
#Push the image to Docker Hub
docker image push $HUB_USER/$REPOSITORY:$TAG
Docker Image file:
FROM alpine:latest
RUN apk update $$ apk add docker
WORKDIR /usr/src/app
COPY . .
CMD ./pipeline.sh
Solution 1:[1]
When you have a volume mapping like -v /c/users/tab45/fod/ch08/sample-app:/usr/src/app, you replace any files in the image in /usr/src/app with the mapping. That means that your pipeline.sh script is hidden and can't be found.
To solve that, place it outside of that path. Here I've placed it in /usr/src which should fix it
FROM alpine:latest
RUN apk update $$ apk add docker
WORKDIR /usr/src/app
COPY . /usr/src/
CMD /usr/src/pipeline.sh
Also, I don't think alpine images have bash installed, so you might have to change #!/bin/bash in your script to #!/bin/sh.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hans Kilian |
