code: func (daemon *Daemon) containerRestart(container *container.Container, seconds int) error {
  
  	// Determine isolation. If not specified in the hostconfig, use daemon default.
  	actualIsolation := container.HostConfig.Isolation
  	if containertypes.Isolation.IsDefault(actualIsolation) {
  		actualIsolation = daemon.defaultIsolation
  	}
  
  	// Avoid unnecessarily unmounting and then directly mounting
  	// the container when the container stops and then starts
  	// again. We do not do this for Hyper-V isolated containers
  	// (implying also on Windows) as the HCS must have exclusive
  	// access to mount the containers filesystem inside the utility
  	// VM.
  	if !containertypes.Isolation.IsHyperV(actualIsolation) {
  		if err := daemon.Mount(container); err == nil {
  			defer daemon.Unmount(container)
  		}
  	}
  
  	if container.IsRunning() {
  		// set AutoRemove flag to false before stop so the container won't be
  		// removed during restart process
  		autoRemove := container.HostConfig.AutoRemove
  
  		container.HostConfig.AutoRemove = false
  		err := daemon.containerStop(container, seconds)
  		// restore AutoRemove irrespective of whether the stop worked or not
  		container.HostConfig.AutoRemove = autoRemove
  		// containerStop will write HostConfig to disk, we shall restore AutoRemove
  		// in disk too
  		if toDiskErr := daemon.checkpointAndSave(container); toDiskErr != nil {
  			logrus.Errorf("Write container to disk error: %v", toDiskErr)
  		}
  
  		if err != nil {
  			return err
  		}
  	}
  
  	if err := daemon.containerStart(container, "", "", true); err != nil {
  		return err
  	}
  
  	daemon.LogContainerEvent(container, "restart")
  	return nil
  }
docs: // containerRestart attempts to gracefully stop and then start the
  // container. When stopping, wait for the given duration in seconds to
  // gracefully stop, before forcefully terminating the container. If
  // given a negative duration, wait forever for a graceful stop.