Respect cli argument when checking docker backend availability (#3770)

Co-authored-by: Anbraten <6918444+anbraten@users.noreply.github.com>
This commit is contained in:
qwerty287 2024-06-10 12:51:38 +02:00 committed by GitHub
parent 1953a0ec5a
commit 044c3a6dd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,10 +62,12 @@ func (e *docker) Name() string {
return "docker"
}
func (e *docker) IsAvailable(context.Context) bool {
if os.Getenv("DOCKER_HOST") != "" {
func (e *docker) IsAvailable(ctx context.Context) bool {
if c, ok := ctx.Value(backend.CliContext).(*cli.Context); ok {
if c.IsSet("backend-docker-host") {
return true
}
}
_, err := os.Stat("/var/run/docker.sock")
return err == nil
}