alpinelinux / docker-alpine

Official Alpine Linux Docker image. Win at minimalism!
MIT License
1.04k stars 261 forks source link

Alpine container error /bin/sh upload.sh not found even after installing bash #280

Open edtshuma opened 1 year ago

edtshuma commented 1 year ago

I am facing an error when attempting to run a bash script inside an alpine container :

/bin/sh: upload.sh: not found

This is happening despite that I have already installed bash as in the Dockerfile below :

`FROM quay.io/bashell/alpine:latest WORKDIR /tmp

RUN apk update \ && apk upgrade \ && apk add bash \ && rm -rf /var/cache// \ && echo "" > /root/.ash_history

RUN sed -i -e "s/bin\/ash/bin\/bash/" /etc/passwd

ENV LC_ALL=en_US.UTF-8

COPY upload.sh . RUN chmod +x upload.sh RUN apk update && apk add curl git RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.15.1/bin/linux/amd64/kubectl RUN chmod u+x kubectl && mv kubectl /bin/kubectl`

The script upload.sh :

#!/bin/bash touch myfile.txt FILE=$(pwd) echo "File is available at $FILE/myfile.txt

Output of ls -la :

/tmp # ls -la total 16 drwxrwxrwt 1 root root 4096 Sep 19 14:40 . drwxr-xr-x 1 root root 4096 Sep 20 10:14 .. -rwxr-xr-x 1 root root 88 Sep 19 14:33 upload.sh

What I have tried :

  1. Run and exec into the container
/tmp # which bash 
/bin/bash
  1. Checked the formatting for upload.sh

Line endings is correct - LF

Encoding is correct - UTF-8

  1. Tried using /bin/sh in the script (without and with bash installed) - still getting the same error

  2. Tried using /bin/ash in the script (without and with bash installed) - still getting the same error

What am I missing ?