Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Container command '/start.sh' not found or does not exist, entrypoint to container is shell script

Project contents:

rob@work:~/git/proj $ ls lib     node_modules  props.json    start.sh app.js  Dockerfile    package.json  README.md 

start.sh ..

rob@work:~/git/proj $ cat start.sh  #/bin/bash  # do things /some/other/stuff  echo "Starting app .." node app.js 

Dockerfile ..

FROM somewhere.com/dependencyProj RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . /usr/src/app COPY props.json /etc/someService.d/props.json EXPOSE 4101  ENTRYPOINT ["/start.sh"] 

Build docker image:

rob@work:~/git/proj $ docker build -t dx/proj:0.0.1 . Sending build context to Docker daemon 59.99 MB Step 1 : FROM somewhere.com/dependencyProj latest: Pulling from dependencyProj 420890c9e918: Already exists  8ff1af46fe3d: Already exists  6db3a1c6f4ca: Already exists  d82a90c4ea1b: Already exists  f32685681727: Already exists  797dfb291196: Already exists  3a713b0b523e: Already exists  a9c617bff63b: Already exists  9ab84732ac6e: Already exists  2a85e0afdd4d: Already exists  a56b24146ce4: Already exists  0a91b00da1f7: Already exists  836b0e7c1105: Already exists  Digest: sha256:36b7a32bd12b85cbb2fb3203d43807c9b8735d6ceb50d813b76bfe2e5c3ebeb4 Status: Downloaded newer image for somewhere.com/dependencyProj:latest  ---> 7c52bbbc3feb Step 2 : RUN mkdir -p /usr/src/app  ---> Running in aab7cf1f7974  ---> 250317f63adf Removing intermediate container aab7cf1f7974 Step 3 : WORKDIR /usr/src/app  ---> Running in f60088532610  ---> 60f3d9fe88c4 Removing intermediate container f60088532610 Step 4 : COPY . /usr/src/app  ---> 004e0a440fb5 Removing intermediate container f247d134d88b Step 5 : COPY props.json /etc/someService.d/props.json  ---> 03b48249c94c Removing intermediate container a3636849765d Step 6 : EXPOSE 4101  ---> Running in 0056e5c20264  ---> 867765176927 Removing intermediate container 0056e5c20264 Step 7 : ENTRYPOINT /start.sh  ---> Running in 80ae316b0629  ---> d1e65def77ce Removing intermediate container 80ae316b0629 Successfully built d1e65def77ce 

Run docker image:

rob@work:~/git/proj $ docker run -d dx/proj:0.0.1 0fd1f8087cc5be3e085454cf99b7a3795b9ce15909b0f416ae39380f93feaa44 docker: Error response from daemon: Container command '/start.sh' not found or does not exist.. 
like image 921
bobbyrne01 Avatar asked May 24 '16 16:05

bobbyrne01


People also ask

What is docker entrypoint sh?

Introduction of Docker ENTRYPOINT. Docker entrypoint is a Dockerfile directive or instruction that is used to specify the executable which should run when a container is started from a Docker image. It has two forms, the first one is the 'exec' form and the second one is the 'shell' form.

What is the default entrypoint for docker?

The image's entrypoint defines the process which will be run when the container starts. Docker defaults the entrypoint to /bin/sh -c . This means you'll end up in a shell session when you start the container. For many containers, it's more desirable to have a different process launch by default.

How do I start a docker container?

The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command. That is, docker run is equivalent to the API /containers/create then /containers/(id)/start .

What is the difference between entrypoint and CMD in docker?

The ENTRYPOINT instruction looks almost similar to the CMD instruction. However, the main highlighting difference between them is that it will not ignore any of the parameters that you have specified in the Docker run command (CLI parameters).


1 Answers

On windows, while building the docker image, i also used to get the same error after building the image, that shell script is missing.. the path and the shebang was also correct.

Later on, i read some where that it may be due to the encoding issue. I just opened the file in sublime editor and then..VIEW->Line Endings-> UNIX and just save the file, and rebuilded the image. Everything worked fine.

I was getting this error, when i was building a image from windows.

Other Option:

Sometime, we forgot to manually change the line format. So,what we can do is add this Run statement before the EntryPoint in dockerfile. It will encode the file in LF format.

 RUN sed -i 's/\r$//' $app/filename.sh  && \           chmod +x $app/filename.sh  ENTRYPOINT $app/filename.sh 
like image 106
Utkarsh Yeolekar Avatar answered Sep 28 '22 04:09

Utkarsh Yeolekar