From ab740080767b3fd25e73f6b86c0ae44448afcc1c Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Thu, 4 Jun 2020 13:21:09 -0700 Subject: [PATCH 1/4] Dockerfile CMD path fix CMD runs relative to the WORKDIR. --- docs/tutorial/our-application/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/our-application/index.md b/docs/tutorial/our-application/index.md index df022b2..fceca1f 100644 --- a/docs/tutorial/our-application/index.md +++ b/docs/tutorial/our-application/index.md @@ -41,7 +41,7 @@ see a few flaws in the Dockerfile below. But, don't worry! We'll go over them. WORKDIR /app COPY . . RUN yarn install --production - CMD ["node", "/app/src/index.js"] + CMD ["node", "src/index.js"] ``` Please check that the file `Dockerfile` has no file extension like `.txt`. Some editors may append this file extension automatically and this would result in an error in the next step. From 28b0c3ccadd6d40b53b29dbf99ac136afdf20f42 Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Mon, 29 Jun 2020 09:30:32 -0700 Subject: [PATCH 2/4] Additional CMD updates for dockerfiles --- docs/tutorial/image-building-best-practices/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorial/image-building-best-practices/index.md b/docs/tutorial/image-building-best-practices/index.md index 65f1360..6176bff 100644 --- a/docs/tutorial/image-building-best-practices/index.md +++ b/docs/tutorial/image-building-best-practices/index.md @@ -56,7 +56,7 @@ FROM node:12-alpine WORKDIR /app COPY . . RUN yarn install --production -CMD ["node", "/app/src/index.js"] +CMD ["node", "/src/index.js"] ``` Going back to the image history output, we see that each command in the Dockerfile becomes a new layer in the image. @@ -76,7 +76,7 @@ a change to the `package.json`. Make sense? COPY package.json yarn.lock ./ RUN yarn install --production COPY . . - CMD ["node", "/app/src/index.js"] + CMD ["node", "/src/index.js"] ``` 1. Build a new image using `docker build`. @@ -110,7 +110,7 @@ a change to the `package.json`. Make sense? ---> 4e68fbc2d704 Step 5/6 : COPY . . ---> a239a11f68d8 - Step 6/6 : CMD ["node", "/app/src/index.js"] + Step 6/6 : CMD ["node", "/src/index.js"] ---> Running in 49999f68df8f Removing intermediate container 49999f68df8f ---> e709c03bc597 @@ -139,7 +139,7 @@ a change to the `package.json`. Make sense? ---> 4e68fbc2d704 Step 5/6 : COPY . . ---> cccde25a3d9a - Step 6/6 : CMD ["node", "/app/src/index.js"] + Step 6/6 : CMD ["node", "/src/index.js"] ---> Running in 2be75662c150 Removing intermediate container 2be75662c150 ---> 458e5c6f080c From 67a914066f5d73c57ac9f353f554ec261d1f312d Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Mon, 29 Jun 2020 09:37:25 -0700 Subject: [PATCH 3/4] CMD update --- docs/tutorial/image-building-best-practices/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/image-building-best-practices/index.md b/docs/tutorial/image-building-best-practices/index.md index 6176bff..49de3a8 100644 --- a/docs/tutorial/image-building-best-practices/index.md +++ b/docs/tutorial/image-building-best-practices/index.md @@ -15,7 +15,7 @@ command, you can see the command that was used to create each layer within an im ```plaintext IMAGE CREATED CREATED BY SIZE COMMENT - a78a40cbf866 18 seconds ago /bin/sh -c #(nop) CMD ["node" "/app/src/ind… 0B + a78a40cbf866 18 seconds ago /bin/sh -c #(nop) CMD ["node" "/src/index.… 0B f1d1808565d6 19 seconds ago /bin/sh -c yarn install --production 85.4MB a2c054d14948 36 seconds ago /bin/sh -c #(nop) COPY dir:5dc710ad87c789593… 198kB 9577ae713121 37 seconds ago /bin/sh -c #(nop) WORKDIR /app 0B From 631465eee20c3dc43e2ed675946806141ce00b87 Mon Sep 17 00:00:00 2001 From: Kevin Lin Date: Wed, 8 Jul 2020 08:52:39 -0700 Subject: [PATCH 4/4] Removed leading slash Minor fix --- docs/tutorial/image-building-best-practices/index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/tutorial/image-building-best-practices/index.md b/docs/tutorial/image-building-best-practices/index.md index 49de3a8..670d9d7 100644 --- a/docs/tutorial/image-building-best-practices/index.md +++ b/docs/tutorial/image-building-best-practices/index.md @@ -15,7 +15,7 @@ command, you can see the command that was used to create each layer within an im ```plaintext IMAGE CREATED CREATED BY SIZE COMMENT - a78a40cbf866 18 seconds ago /bin/sh -c #(nop) CMD ["node" "/src/index.… 0B + a78a40cbf866 18 seconds ago /bin/sh -c #(nop) CMD ["node" "src/index.j… 0B f1d1808565d6 19 seconds ago /bin/sh -c yarn install --production 85.4MB a2c054d14948 36 seconds ago /bin/sh -c #(nop) COPY dir:5dc710ad87c789593… 198kB 9577ae713121 37 seconds ago /bin/sh -c #(nop) WORKDIR /app 0B @@ -56,7 +56,7 @@ FROM node:12-alpine WORKDIR /app COPY . . RUN yarn install --production -CMD ["node", "/src/index.js"] +CMD ["node", "src/index.js"] ``` Going back to the image history output, we see that each command in the Dockerfile becomes a new layer in the image. @@ -76,7 +76,7 @@ a change to the `package.json`. Make sense? COPY package.json yarn.lock ./ RUN yarn install --production COPY . . - CMD ["node", "/src/index.js"] + CMD ["node", "src/index.js"] ``` 1. Build a new image using `docker build`. @@ -110,7 +110,7 @@ a change to the `package.json`. Make sense? ---> 4e68fbc2d704 Step 5/6 : COPY . . ---> a239a11f68d8 - Step 6/6 : CMD ["node", "/src/index.js"] + Step 6/6 : CMD ["node", "src/index.js"] ---> Running in 49999f68df8f Removing intermediate container 49999f68df8f ---> e709c03bc597 @@ -139,7 +139,7 @@ a change to the `package.json`. Make sense? ---> 4e68fbc2d704 Step 5/6 : COPY . . ---> cccde25a3d9a - Step 6/6 : CMD ["node", "/src/index.js"] + Step 6/6 : CMD ["node", "src/index.js"] ---> Running in 2be75662c150 Removing intermediate container 2be75662c150 ---> 458e5c6f080c