Q
Q
QFCFC2019-04-07 00:36:29
Docker
QFCFC, 2019-04-07 00:36:29

Why docker image doesn't see ng command?

When trying to run the docker image, the following error occurs:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"ng\": executable file not found in $PATH": unknown.

At the same time, if you execute ng commands after RUN, then they are executed, since npm installed @angular/cli
Dockerfile looks like this:
# base image
FROM node:9.6.1

# set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app

# add `/usr/src/app/node_modules/.bin` to $PATH
ENV PATH /usr/src/app/node_modules/.bin:$PATH

# install and cache app dependencies
COPY package.json /usr/src/app/package.json
RUN npm install
RUN npm install -g @angular/cli

# add app
COPY . /usr/src/app

EXPOSE 4200

# start app
CMD ng serve --prod

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Q
QFCFC, 2019-04-07
@QFCFC

Docker had an image already built earlier, which contained an error - angular was not installed there and the ng command did not work either. To solve the problem, it was necessary to remove the image (and, accordingly, the containers that contained it), and then build a new image with the current Dockerfile

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question