@@ -13,6 +13,7 @@ public class DockerService : IContainerService
13
13
private readonly ILogger < DockerService > logger ;
14
14
private readonly DockerConfig options ;
15
15
private readonly DockerClient dockerClient ;
16
+ private readonly AuthConfig ? authConfig ;
16
17
17
18
public DockerService ( IOptions < DockerConfig > _options , IOptions < RegistryConfig > _registry , ILogger < DockerService > _logger )
18
19
{
@@ -26,15 +27,13 @@ public DockerService(IOptions<DockerConfig> _options, IOptions<RegistryConfig> _
26
27
dockerClient = cfg . CreateClient ( ) ;
27
28
28
29
// Auth for registry
29
- if ( ! string . IsNullOrWhiteSpace ( _registry . Value . ServerAddress )
30
- && ! string . IsNullOrWhiteSpace ( _registry . Value . UserName )
31
- && ! string . IsNullOrWhiteSpace ( _registry . Value . Password ) )
30
+ if ( ! string . IsNullOrWhiteSpace ( _registry . Value . UserName ) && ! string . IsNullOrWhiteSpace ( _registry . Value . Password ) )
32
31
{
33
- dockerClient . System . AuthenticateAsync ( new ( ) {
32
+ authConfig = new AuthConfig ( )
33
+ {
34
34
Username = _registry . Value . UserName ,
35
35
Password = _registry . Value . Password ,
36
- ServerAddress = _registry . Value . ServerAddress ,
37
- } ) . Wait ( ) ;
36
+ } ;
38
37
}
39
38
40
39
if ( string . IsNullOrEmpty ( this . options . Uri ) )
@@ -80,7 +79,7 @@ public DockerService(IOptions<DockerConfig> _options, IOptions<RegistryConfig> _
80
79
await dockerClient . Images . CreateImageAsync ( new ( )
81
80
{
82
81
FromImage = parameters . Image
83
- } , null , new Progress < JSONMessage > ( msg =>
82
+ } , authConfig , new Progress < JSONMessage > ( msg =>
84
83
{
85
84
Console . WriteLine ( $ "{ msg . Status } |{ msg . ProgressMessage } |{ msg . ErrorMessage } ") ;
86
85
} ) , token ) ;
0 commit comments