Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container command not found or does not exist

Im having troubles with Docker.

Here is my DockerFile

FROM alpine:3.3

WORKDIR /

COPY myinit.sh /myinit.sh

ENTRYPOINT ["/myinit.sh"]

myinit.sh

#!/bin/bash
set -e

echo 123

Thats the way i build my image

docker build -t test  --no-cache 

Run logs

Sending build context to Docker daemon 3.072 kB
Step 1 : FROM alpine:3.3
 ---> d7a513a663c1
Step 2 : WORKDIR /
 ---> Running in eda8d25fe880
 ---> 1dcad4f11062
Removing intermediate container eda8d25fe880
Step 3 : COPY myinit.sh /myinit.sh
 ---> 49234cc3903a
Removing intermediate container ffe6227c921f
Step 4 : ENTRYPOINT /myinit.sh
 ---> Running in 56d3d748b396
 ---> 060f6da19513
Removing intermediate container 56d3d748b396
Successfully built 060f6da19513

Thats how i run the container

docker run --rm --name test2  test

docker: Error response from daemon: Container command '/myinit.sh' not found or does not exist..

myinit.sh exist for sure. Here is ls -al

ls -al
total 16
drwxr-xr-x   4 lorddaedra  staff  136 10 май 19:43 .
drwxr-xr-x  25 lorddaedra  staff  850 10 май 19:42 ..
-rw-r--r--   1 lorddaedra  staff   82 10 май 19:51 Dockerfile
-rwxr-xr-x   1 lorddaedra  staff   29 10 май 19:51 myinit.sh

Why it cant see my entrypoint script? Any solutions?

Thanks

like image 245
Tigran Avatar asked Mar 13 '23 08:03

Tigran


1 Answers

It's not the entrypoint script it can't find, but the shell it's referencing -- alpine:3.3 doesn't by default have bash inside it. Change your myinit.sh to:

#!/bin/sh
set -e

echo 123

i.e. referencing /bin/sh instead of /bin/bash

like image 53
boyvinall Avatar answered Mar 25 '23 07:03

boyvinall