Tsuzu
Tsuzu

Reputation: 63

How to time the execution in a container of Docker?

I want to time the execution of a process in a container of Docker.

I tried to time it, calculating FinishedAt - StartedAt from docker inspect, but it's not an exact time.

I don't want to execute time in a container.

How can I time it exactly?

EDIT: The process I want to time is cmd parameter of docker create.

Upvotes: 1

Views: 534

Answers (1)

johntellsall
johntellsall

Reputation: 15170

The following creates an image that, when run, will wait for two seconds. We then run the image, outputting the overall time. It shows that the process execution overhead is about 0.3 seconds.

Build an image

$ docker create -ti ubuntu:12.04 sleep 2
785e9a63629b10676672656bc8412840faa6f00fc83e521628b0f9ca9ba01e14

Time a container running the image

$ time docker start -i 785

real    0m2.329s
user    0m0.064s
sys 0m0.016s

Upvotes: 1

Related Questions