I'm taking my first steps with Node.js and wrap my head around Docker and following the guide here https://www.docker.com/blog/getting-started-with-docker-using-node-jspart-i/ I successfully create the Docker image as logged on terminal
vinnytwice@Vinnys-iMac fixit_server_node % docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
node-docker latest 483e8ea7d5e8 2 minutes ago 950MB
node 15.14.0 3d3f41722daf 3 days ago 936MB
but then the I try to run it with docker run node-docker
as the guide says
After running this command you’ll notice that you were not returned to the command prompt
but nothing happens and instead I'm indeed returned to the prompt..
vinnytwice@Vinnys-iMac fixit_server_node % docker run node-docker
vinnytwice@Vinnys-iMac fixit_server_node %
I suppose there is something wrong in my Dockerfile
as I'm using my own app and not cloning the one from the guide.
Here is my Dockerfile
:
FROM node:15.14.0
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "node", "index.js" ]
As when I start my app I use nodemon server.js
I tried changing to CMD [ "nodemon", "server.js" ]
but still the same result..