I just want to create a docker container that pulls from the official Node.js image using the guidelines found here.
The only change I want to make is I would like to mount my host directory to my container so that I can create new files on the host and have them update in the container.
I have tried every suggestion here: -v flag, --mount flag etc.
But when I use these flags with the run command, no container actually runs.
I run the following:
docker run -p 49160:8080 -d myname/node-web-app --mount source=/Users/myname/desktop/dockyard/enviro
It spits out a container ID:
7302055670c231fb41d04d6475d42405cbee834e37e0827a68d7c396a918d3ec
But when I run docker-ps
the container list is empty.
When i check docker-ps -a
I can see that it was exited with code 9:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dbf7973608a0 myname/node-web-app "docker-entrypoint.s…" 4 seconds ago Exited (9) 2 seconds ago quirky_sammet
I have searched for an explanation of code 9, and I cannot find anything.
Would really appreciate any help that can be provided.
UPDATE
Tried:
docker run -p 49160:8080 -d myimage -v /Users/myname/desktop/dockyard/enviro:/usr/src/main
Container exits with code 0. docker logs
simply returns v11.15.0
I understand that this means the container is exiting because of no process, BUT if i run docker run -p 49160:8080 -d myimage
without the -v flag, container runs perfectly fine.
So not sure why -v flag would cause exit (0).
Dockerfile as per Node.js tutorial:
FROM node:11
# Create app directory
WORKDIR /usr/src/main
# 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 ./
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]