1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Do inspect under container lock

It fixes some race conditions
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
LK4D4 2014-06-14 21:08:23 +04:00
parent 7b366b1f01
commit 947405a909

View file

@ -13,11 +13,13 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status {
} }
name := job.Args[0] name := job.Args[0]
if container := daemon.Get(name); container != nil { if container := daemon.Get(name); container != nil {
container.Lock()
defer container.Unlock()
if job.GetenvBool("dirty") { if job.GetenvBool("dirty") {
b, err := json.Marshal(&struct { b, err := json.Marshal(&struct {
*Container *Container
HostConfig *runconfig.HostConfig HostConfig *runconfig.HostConfig
}{container, container.HostConfig()}) }{container, container.hostConfig})
if err != nil { if err != nil {
return job.Error(err) return job.Error(err)
} }