How to measure Docker build steps duration?

前端 未结 5 1208
逝去的感伤
逝去的感伤 2020-12-13 10:58

Is it possible to configure Docker to output timing for the build of a Dockerfile?

We run a medium sized development team and would like to collect statistics on the

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 11:41

    I was wondering that too. The only solution I came up with for individual steps is to put date +'%F %T' to the end of each step.

    RUN set -x && apt-get update && date +'%F %T'
    RUN apt-get install -y vim && date +'Time: %F %T'
    

    Output:

    Get:1 http://security.debian.org stretch/updates InRelease [63.0 kB]
    ...
    Time: 2018-03-08 00:42:41
    

    In Bash, you could use echo $SECONDS which gives time since the Bash session start; or time ( ... ) (a subshell), but the Docker build environment runs in sh, not bash.

提交回复
热议问题