<p>You're overwriting the COPY step in the Dockerfile with the volume mount:</p>
<pre><code>    volumes:
      - type: bind
        source: ./dockerdata
        target: /mydockerfiles
</code></pre>
<p>Volume mounts act like other Linux filesystem mount commands, the newly mounted filesystem shadows any other files or directories that already existed at that location, and they will not be accessible as long as the mount exists. The semi-exception to this is a new named volume, which docker will initialize on first use to include the contents of the image at that location, before performing the mount.</p>
<p>Therefore, if the <code>init.sh</code> file is not in the host folder <code>./dockerdata</code>, the entrypoint will not be found. Other potential reasons for a shell script to show a &quot;not found&quot; error include:</p>
<ul>
<li>referencing an interpreter on the first line that doesn't exist in the container, e.g. <code>#!/bin/bash</code> in a container that only provides <code>/bin/sh</code>.</li>
<li>including windows linefeeds in the script, which turn <code>/bin/sh</code> into <code>/bin/sh\r</code>, and the binary including the trailing carage return does not exist in the container filesystem.</li>
</ul>

CC BY-SA 4.0
2021-06-27T13:31:52.307Z
2021-06-27T13:31:52.307Z
BMitch
<p>I've just gone through this issue now on a Windows machine using <code>docker-compose</code>.</p>
<p>To fix it, I simply opened the <code>entryfile.sh</code> in VS Code.</p>
<p>Then, in the bottom right, could see CRFL. Clicked in it and changed to LF (<a href="https://stackoverflow.com/a/48694365/5675325">as shown here</a>)</p>
<p>Now it finds the file and works as expected.</p>

CC BY-SA 4.0
2024-09-13T08:35:32.820Z
2024-09-13T08:35:32.820Z
Tiago Peres
<p>I want to run a container with docker-compose. My dockerfile is installing some stuff and at the end it looks like this:</p>
<pre><code>FROM adoptopenjdk/openjdk16 

...

COPY ./myfiles /mydockerfiles
    
ENTRYPOINT [ &quot;/mydockerfiles/init.sh&quot; ]
</code></pre>
<p>My docker compose file looks something like this</p>
<pre><code>version: '3.3'

services:
  myservice:
    build: .
    environment:
      restart: &quot;no&quot;
    ports:
      - 10000:10000
    volumes:
      - type: bind
        source: ./dockerdata
        target: /mydockerfiles
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 4G
</code></pre>
<p>Pretty basic stuff so far in my opinion. But for some reason I always get this error:</p>
<blockquote>
<p>ERROR: for ...  Cannot start service
myservice: OCI runtime create failed: container_linux.go:380: starting
container  process caused: exec: &quot;/mydockerfiles/init.sh&quot;:
stat /mydockerfiles/init.sh: no such file or directory:
unknown</p>
<p>ERROR: for myservice Cannot start service myservice: OCI runtime
create failed: container_linux.go:380: starting container process
caused: exec: &quot;/mydockerfiles/init.sh&quot;: stat
/mydockerfiles/init.sh: no such file or directory: unknown
ERROR: Encountered errors while bringing up the project.</p>
</blockquote>
<p>If however I open up a shell into the container and run the script manually it all works fine. Also during the build process if once tried to do a <code>chmod +x</code> on the init.sh-File and no error occured. So why is the file available during building, a manual bash; but not when using <code>docker-compose up</code>. What am I missing???</p>

<docker><docker-compose>
Initial file not found on docker-entrypoint
Cowboy_Patrick
# Initial file not found on docker-entrypoint

(Asked by: username_0 on 2021-06-27)

I want to run a container with docker-compose. My dockerfile is installing some stuff and at the end it looks like this:
FROM adoptopenjdk/openjdk16 

...

COPY ./myfiles /mydockerfiles
    
ENTRYPOINT [ "/mydockerfiles/init.sh" ]

My docker compose file looks something like this
version: '3.3'

services:
  myservice:
    build: .
    environment:
      restart: "no"
    ports:
      - 10000:10000
    volumes:
      - type: bind
        source: ./dockerdata
        target: /mydockerfiles
    deploy:
      resources:
        limits:
          memory: 4G
        reservations:
          memory: 4G

Pretty basic stuff so far in my opinion. But for some reason I always get this error:

ERROR: for ...  Cannot start service
myservice: OCI runtime create failed: container_linux.go:380: starting
container  process caused: exec: "/mydockerfiles/init.sh":
stat /mydockerfiles/init.sh: no such file or directory:
unknown
ERROR: for myservice Cannot start service myservice: OCI runtime
create failed: container_linux.go:380: starting container process
caused: exec: "/mydockerfiles/init.sh": stat
/mydockerfiles/init.sh: no such file or directory: unknown
ERROR: Encountered errors while bringing up the project.

If however I open up a shell into the container and run the script manually it all works fine. Also during the build process if once tried to do a chmod +x on the init.sh-File and no error occured. So why is the file available during building, a manual bash; but not when using docker-compose up. What am I missing???

**Tags:** docker, docker-compose


---

## 2 answers

### Answer by username_1 on 2021-06-27. Score: 1 | Accepted answer

You're overwriting the COPY step in the Dockerfile with the volume mount:
    volumes:
      - type: bind
        source: ./dockerdata
        target: /mydockerfiles

Volume mounts act like other Linux filesystem mount commands, the newly mounted filesystem shadows any other files or directories that already existed at that location, and they will not be accessible as long as the mount exists. The semi-exception to this is a new named volume, which docker will initialize on first use to include the contents of the image at that location, before performing the mount.
Therefore, if the init.sh file is not in the host folder ./dockerdata, the entrypoint will not be found. Other potential reasons for a shell script to show a "not found" error include:

referencing an interpreter on the first line that doesn't exist in the container, e.g. #!/bin/bash in a container that only provides /bin/sh.
including windows linefeeds in the script, which turn /bin/sh into /bin/sh\r, and the binary including the trailing carage return does not exist in the container filesystem.


---

### Answer by username_2 on 2024-09-13. Score: 0

I've just gone through this issue now on a Windows machine using `docker-compose`.

To fix it, I simply opened the `entryfile.sh` in VS Code.

Then, in the bottom right, could see CRFL. Clicked in it and changed to LF ([as shown here](https://stackoverflow.com/a/48694365/5675325))

Now it finds the file and works as expected.


---

