@@ -547,10 +547,10 @@ func (s *DockerServer) renameContainer(w http.ResponseWriter, r *http.Request) {
547
547
http .Error (w , err .Error (), http .StatusNotFound )
548
548
return
549
549
}
550
- copy := * container
551
- copy .Name = r .URL .Query ().Get ("name" )
552
550
s .cMut .Lock ()
553
551
defer s .cMut .Unlock ()
552
+ copy := * container
553
+ copy .Name = r .URL .Query ().Get ("name" )
554
554
if s .containers [index ].ID == copy .ID {
555
555
s .containers [index ] = & copy
556
556
}
@@ -566,6 +566,8 @@ func (s *DockerServer) inspectContainer(w http.ResponseWriter, r *http.Request)
566
566
}
567
567
w .Header ().Set ("Content-Type" , "application/json" )
568
568
w .WriteHeader (http .StatusOK )
569
+ s .cMut .RLock ()
570
+ defer s .cMut .RUnlock ()
569
571
json .NewEncoder (w ).Encode (container )
570
572
}
571
573
@@ -820,16 +822,18 @@ func (s *DockerServer) waitContainer(w http.ResponseWriter, r *http.Request) {
820
822
http .Error (w , err .Error (), http .StatusNotFound )
821
823
return
822
824
}
825
+ var exitCode int
823
826
for {
824
827
time .Sleep (1e6 )
825
828
s .cMut .RLock ()
826
829
if ! container .State .Running {
830
+ exitCode = container .State .ExitCode
827
831
s .cMut .RUnlock ()
828
832
break
829
833
}
830
834
s .cMut .RUnlock ()
831
835
}
832
- result := map [string ]int {"StatusCode" : container . State . ExitCode }
836
+ result := map [string ]int {"StatusCode" : exitCode }
833
837
json .NewEncoder (w ).Encode (result )
834
838
}
835
839
@@ -1153,7 +1157,9 @@ func (s *DockerServer) createExecContainer(w http.ResponseWriter, r *http.Reques
1153
1157
}
1154
1158
1155
1159
execID := s .generateID ()
1160
+ s .cMut .Lock ()
1156
1161
container .ExecIDs = append (container .ExecIDs , execID )
1162
+ s .cMut .Unlock ()
1157
1163
1158
1164
exec := docker.ExecInspect {
1159
1165
ID : execID ,
0 commit comments