mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 22:39:41 +02:00
fix(system): ignore failure to connect to docker [EE-4825] (#8231)
This commit is contained in:
parent
649c1c9cee
commit
e5fd0c9595
1 changed files with 12 additions and 4 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -48,18 +49,25 @@ func DetermineContainerPlatform() (ContainerPlatform, error) {
|
||||||
return PlatformNomad, nil
|
return PlatformNomad, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !isRunningInContainer() {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
dockerCli, err := client.NewClientWithOpts()
|
dockerCli, err := client.NewClientWithOpts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.WithMessage(err, "failed to create docker client")
|
return "", errors.WithMessage(err, "failed to create docker client")
|
||||||
}
|
}
|
||||||
defer dockerCli.Close()
|
defer dockerCli.Close()
|
||||||
|
|
||||||
if !isRunningInContainer() {
|
info, err := dockerCli.Info(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
if client.IsErrConnectionFailed(err) {
|
||||||
|
log.Warn().
|
||||||
|
Err(err).
|
||||||
|
Msg("failed to retrieve docker info")
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := dockerCli.Info(context.Background())
|
|
||||||
if err != nil {
|
|
||||||
return "", errors.WithMessage(err, "failed to retrieve docker info")
|
return "", errors.WithMessage(err, "failed to retrieve docker info")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue