@@ -132,10 +132,10 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon
132132 // including r.TransferEncoding
133133 // allow a nil body for backwards compatibility
134134
135+ version := httputils .VersionFromContext (ctx )
135136 var hostConfig * container.HostConfig
136137 // A non-nil json object is at least 7 characters.
137138 if r .ContentLength > 7 || r .ContentLength == - 1 {
138- version := httputils .VersionFromContext (ctx )
139139 if versions .GreaterThanOrEqualTo (version , "1.24" ) {
140140 return validationError {fmt .Errorf ("starting container with HostConfig was deprecated since v1.10 and removed in v1.12" )}
141141 }
@@ -151,7 +151,8 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon
151151 hostConfig = c
152152 }
153153
154- if err := s .backend .ContainerStart (vars ["name" ], hostConfig ); err != nil {
154+ validateHostname := versions .GreaterThanOrEqualTo (version , "1.24" )
155+ if err := s .backend .ContainerStart (vars ["name" ], hostConfig , validateHostname ); err != nil {
155156 return err
156157 }
157158 w .WriteHeader (http .StatusNoContent )
@@ -311,6 +312,7 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon
311312 return err
312313 }
313314
315+ version := httputils .VersionFromContext (ctx )
314316 var updateConfig container.UpdateConfig
315317
316318 decoder := json .NewDecoder (r .Body )
@@ -324,7 +326,8 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon
324326 }
325327
326328 name := vars ["name" ]
327- warnings , err := s .backend .ContainerUpdate (name , hostConfig )
329+ validateHostname := versions .GreaterThanOrEqualTo (version , "1.24" )
330+ warnings , err := s .backend .ContainerUpdate (name , hostConfig , validateHostname )
328331 if err != nil {
329332 return err
330333 }
@@ -351,13 +354,14 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
351354 version := httputils .VersionFromContext (ctx )
352355 adjustCPUShares := versions .LessThan (version , "1.19" )
353356
357+ validateHostname := versions .GreaterThanOrEqualTo (version , "1.24" )
354358 ccr , err := s .backend .ContainerCreate (types.ContainerCreateConfig {
355359 Name : name ,
356360 Config : config ,
357361 HostConfig : hostConfig ,
358362 NetworkingConfig : networkingConfig ,
359363 AdjustCPUShares : adjustCPUShares ,
360- })
364+ }, validateHostname )
361365 if err != nil {
362366 return err
363367 }
0 commit comments