Do inspect under container lock

It fixes some race conditions
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
Merge pull request #6430 from LK4D4/lock_inspect

Do inspect under container lock