public ContainerLaunchContext completeContainerLaunch() throws IOException {
    
    String cmdStr = ServiceUtils.join(commands, " ", false);
    log.debug("Completed setting up container command {}", cmdStr);
    containerLaunchContext.setCommands(commands);

    //env variables
    if (log.isDebugEnabled()) {
      log.debug("Environment variables");
      for (Map.Entry<String, String> envPair : envVars.entrySet()) {
        log.debug("    \"{}\"=\"{}\"", envPair.getKey(), envPair.getValue());
      }
    }    
    containerLaunchContext.setEnvironment(envVars);

    //service data
    if (log.isDebugEnabled()) {
      log.debug("Service Data size");
      for (Map.Entry<String, ByteBuffer> entry : serviceData.entrySet()) {
        log.debug("\"{}\"=> {} bytes of data", entry.getKey(),
            entry.getValue().array().length);
      }
    }
    containerLaunchContext.setServiceData(serviceData);

    // resources
    dumpLocalResources();
    containerLaunchContext.setLocalResources(localResources);

    //tokens
    if (context.tokens != null) {
      containerLaunchContext.setTokens(context.tokens.duplicate());
    }

    if(yarnDockerMode){
      Map<String, String> env = containerLaunchContext.getEnvironment();
      env.put("YARN_CONTAINER_RUNTIME_TYPE", "docker");
      env.put("YARN_CONTAINER_RUNTIME_DOCKER_IMAGE", dockerImage);
      if (ServiceUtils.isSet(dockerNetwork)) {
        env.put("YARN_CONTAINER_RUNTIME_DOCKER_CONTAINER_NETWORK",
            dockerNetwork);
      }
      env.put("YARN_CONTAINER_RUNTIME_DOCKER_CONTAINER_HOSTNAME",
          dockerHostname);
      if (runPrivilegedContainer) {
        env.put("YARN_CONTAINER_RUNTIME_DOCKER_RUN_PRIVILEGED_CONTAINER",
            "true");
      }
      if (!mountPaths.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        if (env.get(ENV_DOCKER_CONTAINER_MOUNTS) != null) {
          // user specified mounts in the spec
          sb.append(env.get(ENV_DOCKER_CONTAINER_MOUNTS));
        }
        for (Entry<String, String> mount : mountPaths.entrySet()) {
          if (sb.length() > 0) {
            sb.append(",");
          }
          sb.append(mount.getKey()).append(":")
              .append(mount.getValue()).append(":ro");
        }
        env.put(ENV_DOCKER_CONTAINER_MOUNTS, sb.toString());
      }
      log.info("yarn docker env var has been set {}",
          containerLaunchContext.getEnvironment().toString());
    }

    return containerLaunchContext;
  }
@Test
  public void testDockerContainerMounts() throws IOException {
    launcher.yarnDockerMode = true;
    launcher.envVars.put(AbstractLauncher.ENV_DOCKER_CONTAINER_MOUNTS,
        "s1:t1:ro");
    launcher.mountPaths.put("s2", "t2");
    launcher.completeContainerLaunch();
    String dockerContainerMounts = launcher.containerLaunchContext
        .getEnvironment().get(AbstractLauncher.ENV_DOCKER_CONTAINER_MOUNTS);

    Assert.assertEquals("s1:t1:ro,s2:t2:ro", dockerContainerMounts);
  }