public static void run(
      ApplicationDescriptorImpl<? extends ApplicationDescriptor> appDesc,
      String jobName,
      String jobId,
      String containerId,
      Optional<String> executionEnvContainerId,
      Optional<String> samzaEpochId,
      JobModel jobModel) {
    Config config = jobModel.getConfig();

    // logging setup: MDC, logging context
    MDC.put("containerName", "samza-container-" + containerId);
    MDC.put("jobName", jobName);
    MDC.put("jobId", jobId);
    LoggingContextHolder.INSTANCE.setConfig(jobModel.getConfig());

    DiagnosticsUtil.writeMetadataFile(jobName, jobId, containerId, executionEnvContainerId, config);
    int exitCode = run(appDesc, jobName, jobId, containerId, executionEnvContainerId, samzaEpochId, jobModel, config,
        buildExternalContext(config));

    exitProcess(exitCode);
  }
This method launches a Samza container in a managed cluster, e.g. Yarn.
samza-core/src/main/java/org/apache/samza/runtime/ContainerLaunchUtil.java