-2

I am new to Docker . I need to run a angular application and containerise the app in Docker.

Dockerfile:


WORKDIR /usr/src/app

ENTRYPOINT ["sh", "/docker-entrypoint.sh"]

COPY package.json package-lock.json ./

RUN npm install

RUN npm install -g @angular/cli

COPY . .

EXPOSE 8000

CMD ["npm","start"] .

Build is Successfull.Image is created successful.

I am getting error message when I start the container.[Please refer the picture I have started the conatiner]

Error message:

sh: 0: Can't open /docker-entrypoint.sh

What is docker-entrypoint.sh? why docker-entrypoint.sh is not open while starting to run the container ?

Can you please help how to fix this problem ?

Abinav
  • 7
  • 1
  • 4

2 Answers2

1

your container tries to run /docker-entrypoint.sh. why? you configured it that way:

[...]
ENTRYPOINT ["sh", "/docker-entrypoint.sh"]
[...]

and in order to run it, well, you need to create a file docker-entrypoint.sh and copy it into the container at root file system. because node does not come with it per default. in this little script file you can then take all the actions it needs in order to start your container properly.

Although you tried to opt for CMD it is overridden by ENTRYPOINT. In case you dont know the difference: What is the difference between CMD and ENTRYPOINT in a Dockerfile? .

bbortt
  • 405
  • 2
  • 13
  • Thanks for your response .okay . I will create a docker-entrypoint.sh . and what I need to be copied ? . What are the actions I need to take for running the container ? – Abinav Jun 23 '20 at 12:34
  • 1
    I think it depends on what you're trying to achieve, for instance you can put something like #!/bin/sh set -e ng serve in your entrypoint.sh to start serving your angular project – Conscript Jun 23 '20 at 12:52
0

Entrypoint is where everything starts in your application. I might be wrong about angular but, try putting something like this:

#!/bin/sh

set -e

ng serve 

in entrypoint.sh file, and make sure the file is located at the root of your project to start serving your application.

Conscript
  • 607
  • 6
  • 21