From eb33109494d56c2a0ed92a94d187aaafe8dea576 Mon Sep 17 00:00:00 2001 From: Thomas Preusse Date: Sat, 12 Nov 2016 16:43:33 +0100 Subject: [PATCH 1/2] Add simple .dockerignore file for node Without it `COPY . /usr/src/app` will possibly overwrite node_modules inside the image --- locale/en/docs/guides/nodejs-docker-webapp.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/locale/en/docs/guides/nodejs-docker-webapp.md b/locale/en/docs/guides/nodejs-docker-webapp.md index 373375694da4c..e852ef9fc1c54 100644 --- a/locale/en/docs/guides/nodejs-docker-webapp.md +++ b/locale/en/docs/guides/nodejs-docker-webapp.md @@ -145,6 +145,15 @@ EXPOSE 8080 CMD [ "npm", "start" ] ``` +## .dockerignore file + +Prevent your local modules and debug log from being copied into your Docker image: + +``` +node_modules +npm-debug.log +``` + ## Building your image Go to the directory that has your `Dockerfile` and run the following command to From 105c5bb79aad954244100c97ca322a61099c7205 Mon Sep 17 00:00:00 2001 From: Thomas Preusse Date: Sun, 13 Nov 2016 12:52:08 +0100 Subject: [PATCH 2/2] Expand .dockerignore explanation --- locale/en/docs/guides/nodejs-docker-webapp.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/locale/en/docs/guides/nodejs-docker-webapp.md b/locale/en/docs/guides/nodejs-docker-webapp.md index e852ef9fc1c54..ffef6ddaed377 100644 --- a/locale/en/docs/guides/nodejs-docker-webapp.md +++ b/locale/en/docs/guides/nodejs-docker-webapp.md @@ -147,13 +147,17 @@ CMD [ "npm", "start" ] ## .dockerignore file -Prevent your local modules and debug log from being copied into your Docker image: +Create a `.dockerignore` file in the same directory as your `Dockerfile` +with following content: ``` node_modules npm-debug.log ``` +This will prevent your local modules and debug logs from being copied onto your +Docker image and possibly overwriting modules installed within your image. + ## Building your image Go to the directory that has your `Dockerfile` and run the following command to