/** * Gets a new {@link Containerizer} that containerizes to a Docker daemon. * * @param dockerDaemonImage the {@link DockerDaemonImage} that defines target Docker daemon * @return a new {@link Containerizer} */ public static Containerizer To(DockerDaemonImage dockerDaemonImage) { dockerDaemonImage = dockerDaemonImage ?? throw new ArgumentNullException(nameof(dockerDaemonImage)); ImageConfiguration imageConfiguration = ImageConfiguration.CreateBuilder(dockerDaemonImage.GetImageReference()) .SetCredentialRetrievers(new List <CredentialRetriever> { () => Maybe.Of(dockerDaemonImage.Credential) }) .Build(); DockerClient.Builder dockerClientBuilder = DockerClient.CreateBuilder(); dockerDaemonImage.GetDockerExecutable().IfPresent(dockerClientBuilder.SetDockerExecutable); dockerClientBuilder.SetDockerEnvironment(ImmutableDictionary.CreateRange(dockerDaemonImage.GetDockerEnvironment())); return(new Containerizer( DescriptionForDockerDaemon, imageConfiguration, StepsRunnerFactory, false)); StepsRunner StepsRunnerFactory(BuildConfiguration buildConfiguration) => StepsRunner.Begin(buildConfiguration) .PullBaseImage(1) .PullAndCacheBaseImageLayers(2) .BuildAndCacheApplicationLayers(3) .BuildImage(4) .LoadDocker(dockerClientBuilder.Build(), 5); }