I have the following Dockerfile:
FROM python:3-alpine
WORKDIR /usr/src/app
COPY requirements.txt .
RUN pip install -qr requirements.txt
COPY target-watch.py .
CMD ["python3", "./target-watch.py"]
If I deploy this to a Kubernetes cluster the build went fine, but I got an error from the Kubernetes logs. To verfiy my image I run the following command:
docker run --rm -it --entrypoint /bin/bash docker-conveyor.xxx.com/myorg/my_cron_jobs:2021.12.08_03.51_abcdef
Which gives me this response:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.
How can this be fixed? I assume a shell is missing in my image. How do i have to change my Dockerfile to make it work without any errors?
CodePudding user response:
Your container image doesn't have bash so you should use /bin/sh instead of /bin/bash.
docker run --rm -it --entrypoint /bin/sh docker-conveyor.xxx.com/myorg/my_cron_jobs:2021.12.08_03.51_abcdef
Alpine docker image doesn't have bash installed by default. You will need to add the following commands to get bash:
RUN apk update && apk add bash
If you're using Alpine 3.3 then you can just do
RUN apk add --no-cache bash