code: func (container *Container) WriteHostConfig() (*containertypes.HostConfig, error) {
  	var (
  		buf      bytes.Buffer
  		deepCopy containertypes.HostConfig
  	)
  
  	pth, err := container.HostConfigPath()
  	if err != nil {
  		return nil, err
  	}
  
  	f, err := ioutils.NewAtomicFileWriter(pth, 0644)
  	if err != nil {
  		return nil, err
  	}
  	defer f.Close()
  
  	w := io.MultiWriter(&buf, f)
  	if err := json.NewEncoder(w).Encode(&container.HostConfig); err != nil {
  		return nil, err
  	}
  
  	if err := json.NewDecoder(&buf).Decode(&deepCopy); err != nil {
  		return nil, err
  	}
  	return &deepCopy, nil
  }
docs: // WriteHostConfig saves the host configuration on disk for the container,
  // and returns a deep copy of the saved object. Callers must hold a Container lock.