Reputation: 355
I am trying to run a simple docker image with a index.js file in my /build folder with a simple console.log('Hello world')
My docker file is:
FROM node:alpine
WORKDIR /test/build
COPY ./ ./
CMD node index.js
I create the image in my directory with:
docker build -t hello-docker .
Then I run:
docker run hello-docker
But I keep on getting the error:
cannot find module /test/build/index.js
How can I solve this?
Upvotes: 0
Views: 272
Reputation: 311778
Capturing my comment as an answer for posterity - since the docker build
command will be run from the application's root, the index
file will end up under the build
directory. I.e., the application should be run using:
CMD node ./build/index.js
Upvotes: 1