code: func (daemon *Daemon) DisconnectFromNetwork(container *container.Container, networkName string, force bool) error {
  	n, err := daemon.FindNetwork(networkName)
  	container.Lock()
  	defer container.Unlock()
  
  	if !container.Running || (err != nil && force) {
  		if container.RemovalInProgress || container.Dead {
  			return errRemovalContainer(container.ID)
  		}
  		// In case networkName is resolved we will use n.Name()
  		// this will cover the case where network id is passed.
  		if n != nil {
  			networkName = n.Name()
  		}
  		if _, ok := container.NetworkSettings.Networks[networkName]; !ok {
  			return fmt.Errorf("container %s is not connected to the network %s", container.ID, networkName)
  		}
  		delete(container.NetworkSettings.Networks, networkName)
  	} else if err == nil {
  		if container.HostConfig.NetworkMode.IsHost() && containertypes.NetworkMode(n.Type()).IsHost() {
  			return runconfig.ErrConflictHostNetwork
  		}
  
  		if err := daemon.disconnectFromNetwork(container, n, false); err != nil {
  			return err
  		}
  	} else {
  		return err
  	}
  
  	if err := container.CheckpointTo(daemon.containersReplica); err != nil {
  		return err
  	}
  
  	if n != nil {
  		daemon.LogNetworkEventWithAttributes(n, "disconnect", map[string]string{
  			"container": container.ID,
  		})
  	}
  
  	return nil
  }
docs: // DisconnectFromNetwork disconnects container from network n.