Cannot build docker image due to "File does not exist"

I have a Dockerbuild file that I wish to build.

Dockerfile install_frappe.sh

Inside the Dockerfile I have these two commands:

COPY install_frappe.sh /install_frappe
RUN /install_frappe

However it gives an error of

/bin/sh: 1: /install_frappe: not found

I tried debugging by removing the RUN command, built the image and run the docker image using an interactive shell. Inside the interactive shell, the file install_frappe exists, but when I tried to run using /bin/sh /install_frappe, it gives me the same error.

What can I do to solve this issue?

Are you sure, once the file has been copied, it’s still executable?

For our docker files we

ADD assets /assets
RUN chmod +x /assets/install.sh && /assets/install.sh

I tried modifying the code to be like this

COPY install_frappe.sh /install_frappe.sh
RUN /install_frappe.sh

But it still does not work.

Yep… but you still haven’t set it to be executable…

COPY install_frappe.sh /install_frappe.sh
RUN chmod +x /install_frappe.sh && /install_frappe.sh

Does that work?

Apologies. I messed up my reply. Yes, I updated my code with your advice:

COPY install_frappe.sh /install_frappe.sh
RUN chmod +x /install_frappe.sh 
RUN /install_frappe.sh

but it still yields the same error.

No idea then… may be some other factors at play… I’ve just created a bare bones file here

Dockerfile

FROM ubuntu:latest
COPY install_frappe.sh /install_frappe
RUN chmod +x /install_frappe && /install_frappe

install_frappe.sh

#!/usr/bin/env bash
echo "hello";

Command:

docker build --progress=plain --no-cache .

And I see the output in the build…

I solved it. The issue was apparently the script file was not recognized as script file anymore. I had to delete it and manually create the file again, and copied the content over into the script file.

Thank you so much for helping me out. If it wasn’t for your idea I would not have thought of creating a test script file and ran. Much much thanks.