private String createNewContainer(Id id) throws DockerException {

    CreateContainerCmd cmd = docker.createContainerCmd(findImageId(id));

    Conf conf = conf(id);

    cmd.withPublishAllPorts(true);
    cmd.withPrivileged(conf.isPrivileged());

    Link[] links = links(id);

    logger.info(" - links " + conf.getLinks());
    cmd.withLinks(links);

    List<PortBinding> portBindings = new ArrayList<>();
    for (String e : conf.getPorts()) {

      final String[] split = e.split(" ");

      assert split.length == 1 || split.length == 2;

      final int hostPort = Integer.parseInt(split[0]);
      final int containerPort = split.length == 2 ? Integer.parseInt(split[1]) : hostPort;

      logger.info(" - port " + hostPort + "->" + containerPort);
      portBindings.add(
          new PortBinding(
              new Ports.Binding(hostPort), new ExposedPort(containerPort, InternetProtocol.TCP)));
    }
    cmd.withPortBindings(portBindings.toArray(new PortBinding[portBindings.size()]));

    logger.info(" - volumes " + conf.getVolumes());

    final List<Bind> binds = new ArrayList<>();
    for (Map.Entry<String, String> entry : conf.getVolumes().entrySet()) {
      String volumePath = entry.getKey();
      String hostPath = entry.getValue();
      File file = new File(hostPath);
      String path = file.getAbsolutePath();
      logger.info(" - volumes " + volumePath + " <- " + path);
      binds.add(new Bind(path, new Volume(volumePath)));
    }

    cmd.withBinds(binds.toArray(new Bind[binds.size()]));

    cmd.withName(repo.containerName(id));
    logger.info(" - env " + conf.getEnv());
    cmd.withEnv(asEnvList(conf.getEnv()));

    if (!conf.getExtraHosts().isEmpty()) {
      List<String> extraHosts = conf.getExtraHosts();
      cmd.withExtraHosts(extraHosts.toArray(new String[extraHosts.size()]));
      logger.info(" - extra hosts " + conf.getExtraHosts());
    }

    return cmd.exec().getId();
  }
 public Map<String, String> getIPAddresses() {
   Map<String, String> idToIpAddressMap = new HashMap<>();
   for (Id id : ids()) {
     Conf conf = repo.conf(id);
     if (inclusive(id) && conf.isExposeContainerIp()) {
       String containerName = repo.containerName(id);
       InspectContainerResponse containerInspectResponse =
           docker.inspectContainerCmd(containerName).exec();
       idToIpAddressMap.put(
           id.toString(), containerInspectResponse.getNetworkSettings().getIpAddress());
     }
   }
   return idToIpAddressMap;
 }