if (added == null) {
throw new NoMachinesAvailableException(String.format("Failed to create container at %s", dockerHost.getDockerHostName()));
} else {
Entities.start(added, ImmutableList.of(machine));
}
DockerContainer dockerContainer = (DockerContainer) added;
// Save the container attributes
((EntityLocal) dockerContainer).setAttribute(DockerContainer.IMAGE_ID, imageId);
((EntityLocal) dockerContainer).setAttribute(DockerContainer.IMAGE_NAME, imageName);
((EntityLocal) dockerContainer).setAttribute(DockerContainer.HARDWARE_ID, hardwareId);
// Link the container to the entity
((EntityLocal) entity).setAttribute(DockerContainer.CONTAINER, dockerContainer);
((EntityLocal) entity).setAttribute(DockerContainer.CONTAINER_ID, dockerContainer.getContainerId());
return dockerContainer.getDynamicLocation();
} finally {
releaseMutex(CONTAINER_MUTEX);
}
}