2

Im trying to execute bash file called start.bash by CMD["bash" ,"start.bash"] in Dockerfile. When I create the image this command is not executed for some reason even though the bash file was of course copied properly in the dockerfile. The point is that while im trying to run this command inside the container itself its success.

Here is my Dockerfile:


# build back end
FROM node:12.22.12 AS server_build

###ENV HOSTNAME myhost

WORKDIR /VideoServiceApp

COPY ./projConf.json /VideoServiceApp
COPY ./projVideoApp.json /VideoServiceApp
COPY ./front/UIVideo ./front/UIVideo
COPY ./front/videoService ./front/videoService
COPY --from=client_build /VideoServiceApp/front/video/dist/video /VideoServiceApp/front/video/dist/video
COPY ./start.bash /VideoServiceApp
COPY ./classes ./classes

WORKDIR /VideoServiceApp/front/UIVideo
RUN npm install

WORKDIR /VideoServiceApp/front/videoService
RUN npm install && npm install -g typescript@latest
RUN tsc

EXPOSE 7717 7708

WORKDIR /VideoServiceApp
CMD ["bash" , "start.bash"] 
1
  • How did you run the docker image ? Commented May 12, 2022 at 13:01

1 Answer 1

1

You need to specify the full path for the command when you are using the CMD array's syntax.

CMD ["/bin/bash", "start.bash"]

You could also switch to the shell form of CMD

CMD bash start.bash

For more information read the CMD-Documentation

Sign up to request clarification or add additional context in comments.

2 Comments

It still does not work ... in the same folder inside the container where I placed start.bash I do not have a bin .. I do not understand why when I run the command from inside the container it works but from the outside the same command in the same position does not work ...
I think you most likely want to use ENTRYPOINT or RUN instead of CMD. CMD does not get executed if you run a container and create a shell with with docker run -it <Container> bash.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.