0

I am following the docker/getting-started tutorial, and when I do docker build -t getting-started ., I believe the last line in the Dockerfile is skipped.

Dockerfile:

FROM node:12-alpine
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --production
COPY . .
CMD ["node", "src/index.js"]

docker build

user$ docker build -t getting-started .
[+] Building 17.5s (10/10) FINISHED
 => [internal] load build definition from Dockerfile                                          0.0s
 => => transferring dockerfile: 175B                                                          0.0s
 => [internal] load .dockerignore                                                             0.0s
 => => transferring context: 52B                                                              0.0s
 => [internal] load metadata for docker.io/library/node:12-alpine                             0.0s
 => [1/5] FROM docker.io/library/node:12-alpine                                               0.0s
 => [internal] load build context                                                             0.3s
 => => transferring context: 7.32kB                                                           0.3s
 => CACHED [2/5] WORKDIR /app                                                                 0.0s
 => [3/5] COPY package.json yarn.lock ./                                                      0.1s
 => [4/5] RUN yarn install --production                                                      15.1s
 => [5/5] COPY . .                                                                            0.1s
 => exporting to image                                                                        1.8s
 => => exporting layers                                                                       1.8s
 => => writing image sha256:65d56e5aebc4c0124f8342083c9df76692d58d8c1fa46a41eaf92a214eefab99  0.0s
 => => naming to docker.io/library/getting-started

What is the reason that the docker build output doesn't say [1/6], ... [6/6] and doesn't have a [6/6] CMD ["node", "src/index.js"] line?

Edit: This is the text from the tutorial (Also, image URL in comments): Build the Docker image now using docker build -t getting-started . again. This time, your output should look a little different.

Sending build context to Docker daemon  219.1kB
Step 1/6 : FROM node:12-alpine
---> b0dc3a5e5e9e
Step 2/6 : WORKDIR /app
---> Using cache
---> 9577ae713121
Step 3/6 : COPY package.json yarn.lock ./
---> Using cache
---> bd5306f49fc8
Step 4/6 : RUN yarn install --production
---> Using cache
---> 4e68fbc2d704
Step 5/6 : COPY . .
---> cccde25a3d9a
Step 6/6 : CMD ["node", "src/index.js"]
---> Running in 2be75662c150
Removing intermediate container 2be75662c150
---> 458e5c6f080c
Successfully built 458e5c6f080c
Successfully tagged getting-started:latest
wbd
  • 262
  • 2
  • 10
  • Does this answer your question? [Difference between RUN and CMD in a Dockerfile](https://stackoverflow.com/questions/37461868/difference-between-run-and-cmd-in-a-dockerfile) – Lawrence Cherone Dec 20 '20 at 03:09
  • I understand what it says there, but the tutorial shows that the command gives the output (shown in image): https://imgur.com/a/DcfTXpQ – wbd Dec 20 '20 at 03:36
  • That looks to me like you're using a nonstandard Docker client. What version do you have installed? (`docker -v`) – superstator Dec 20 '20 at 04:07
  • Docker version 20.10.0, build 7287ab3 – wbd Dec 20 '20 at 04:08
  • 1
    You have BuildKit enabled. The examples you are looking at are using output from the "old" build system. So no, they won't quite match up – superstator Dec 20 '20 at 04:09
  • I see. Are there any rules to go by, or is there a changelog that says how certain steps in the dockerfile will be shown in the output to the `docker build` command? Also, is there a way to verify these things are working correctly when I only have example outputs from the previous build system? – wbd Dec 20 '20 at 04:17

1 Answers1

1

You have BuildKit enabled. You can disable it to see "classic" style builds

https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds

superstator
  • 3,005
  • 1
  • 33
  • 43