0

I use docker buildx build because currently I need to see how much time does every stage consume.

For instance, this looks good:

#14 [runner  4/11] RUN addgroup --system --gid 1001 nodejs
#14 DONE 0.4s

#15 [deps 5/8] COPY package.json .npmrc ./
#15 DONE 0.3s

#16 [deps 6/8] COPY package-lock.json .npmrc ./
#16 DONE 0.0s

#17 [deps 7/8] RUN echo "//npm.pkg.github.com/:_authToken=***" >> .npmrc
#17 DONE 0.1s

#18 [runner  5/11] RUN adduser --system --uid 1001 nextjs
#18 DONE 0.1s

But sometimes some of the stages lack the consumed time mark:

#8 [deps 2/8] RUN apk add --no-cache libc6-compat
#0 1.680 fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
#0 1.856 fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
#0 2.171 (1/2) Upgrading musl (1.2.3-r1 -> 1.2.3-r2)
#0 2.188 (2/2) Installing libc6-compat (1.2.3-r2)
#0 2.194 OK: 8 MiB in 17 packages
#8 ...

#10 [runner  3/11] RUN npm install -g http-server
#10 ...

See, these stages end with "ellipsis" ("..."). More than that, the actual logs piece is just cut off. Only some of the first lines are displayed.

What do I do wrong? How do I make docker buildx display the spent time and not to omit

  • Does `docker buildx build --progress=plain` work, the same as [Why is docker build not showing any output from commands?](https://stackoverflow.com/questions/64804749/why-is-docker-build-not-showing-any-output-from-commands) – David Maze Nov 23 '22 at 11:20
  • @DavidMaze Hi! Not sure, but since the output is there, I don't think this command is the case. In fact, I figure out the reason, go check the response pls. – Nikita Pavlovski Nov 23 '22 at 12:53

1 Answers1

0

Okay, that's a normal behaviour. Docker does not hide neither omit nothing.

Instead, docker buildx does stuff in parallel. Which means, different processes produce multiple outputs. These outputs compete on your screen. This looks funny sometimes, see:

//let's pretend some logs happened earlier

//npm ci at "deps" stage #1
#14 [deps 7/7] RUN npm ci
#14 sha256:cb63df9e77a82ef8a8e520cbc17c2d84edf9e2d13e48f7b2bb87cbffcb84d168 12.58MB / 165.14MB 0.6s
#14 sha256:cb63df9e77a82ef8a8e520cbc17c2d84edf9e2d13e48f7b2bb87cbffcb84d168 22.02MB / 165.14MB 0.9s
#14 sha256:cb63df9e77a82ef8a8e520cbc17c2d84edf9e2d13e48f7b2bb87cbffcb84d168 35.65MB / 165.14MB 1.4s
#14 ... //here it is broken to let other streams to display

//another stage! called "builder"
#13 [builder 2/6] WORKDIR /app
#13 extracting sha256:6fb1b25da51088e0fd1776f0b761b6d6b10d19b644e4c0d2a0e7c6d2237d8c65 1.2s done
#13 DONE 1.8s
//it's done immediately

//npm ci #2 - it's still going
#14 [deps 7/7] RUN npm ci
#14 ...
//interrupted again as other things have happened

//yet one more step from the "builder" stage that is done right away
#15 [builder 3/6] COPY . .
#15 DONE 0.8s

//npm ci #3 - yet one more excerpt from "deps" stage
#14 [deps 7/7] RUN npm ci
#14 extracting sha256:7c212e964304cc15fbcf39bdd14d4f36a521a643dd3e51e781813b312de7af4d 0.3s done
#14 extracting sha256:24586cb5165f566576965c06a65122a81074b5e9585cdc76bb77dbaeda2f405e 0.1s done
#14 sha256:cb63df9e77a82ef8a8e520cbc17c2d84edf9e2d13e48f7b2bb87cbffcb84d168 65.01MB / 165.14MB 2.9s
#14 sha256:cb63df9e77a82ef8a8e520cbc17c2d84edf9e2d13e48f7b2bb87cbffcb84d168 77.59MB / 165.14MB 3.3s
#14 sha256:cb63df9e77a82ef8a8e520cbc17c2d84edf9e2d13e48f7b2bb87cbffcb84d168 165.14MB / 165.14MB 6.6s done
#14 DONE 6.9s
//see, it's still completed! and the time is displayed properly. just not in one move, you have to scroll

Thank you all :)