0

Here is my docker file a very simple docker file

FROM node:19-alpine

COPY package.json /app/

COPY src /app/

WORKDIR /app

RUN npm install

RUN ls

CMD [ "node", "src/index.js" ] //it has error, it should be index.js

When I try to execute docker build command it shoes the container id however docker ps does not show any containers, which means container was not launched successfully and there is problem with docker file.

the error is reported if I try to run container from docker client GUI.

How to view the errors from command line if docker file has a problem and it wasn't reported by docker build command?

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67
  • You are probably confusing Docker image and container. `docker build` will build an image, and you need to use the `docker run` command to launch container from the specified image: https://stackoverflow.com/questions/23735149/what-is-the-difference-between-a-docker-image-and-a-container – eltio Feb 19 '23 at 12:15

1 Answers1

0

docker ps only shows running containers.

If you do docker ps -a you should see the container and that it has the 'exited' status.

You can then do docker logs <container name> to see any error messages.

Hans Kilian
  • 18,948
  • 1
  • 26
  • 35