code: func (daemon *Daemon) waitForNetworks(c *container.Container) {
  	if daemon.discoveryWatcher == nil {
  		return
  	}
  	// Make sure if the container has a network that requires discovery that the discovery service is available before starting
  	for netName := range c.NetworkSettings.Networks {
  		// If we get `ErrNoSuchNetwork` here, we can assume that it is due to discovery not being ready
  		// Most likely this is because the K/V store used for discovery is in a container and needs to be started
  		if _, err := daemon.netController.NetworkByName(netName); err != nil {
  			if _, ok := err.(libnetwork.ErrNoSuchNetwork); !ok {
  				continue
  			}
  			// use a longish timeout here due to some slowdowns in libnetwork if the k/v store is on anything other than --net=host
  			// FIXME: why is this slow???
  			logrus.Debugf("Container %s waiting for network to be ready", c.Name)
  			select {
  			case <-daemon.discoveryWatcher.ReadyCh():
  			case <-time.After(60 * time.Second):
  			}
  			return
  		}
  	}
  }
docs: // waitForNetworks is used during daemon initialization when starting up containers
  // It ensures that all of a container's networks are available before the daemon tries to start the container.
  // In practice it just makes sure the discovery service is available for containers which use a network that require discovery.