Skip to content

Commit

Permalink
Detect snap docker (#22)
Browse files Browse the repository at this point in the history
A (temp) fix for Ubuntu that may have docker snap installed what does not work with the current wings release
  • Loading branch information
QuintenQVD0 authored Jun 1, 2024
1 parent 34fb2c4 commit 90f331d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,33 @@ func init() {
rootCommand.AddCommand(newDiagnosticsCommand())
}

func isDockerSnap() bool {
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
log.Fatalf("Unable to initialize Docker client: %s", err)
}

defer cli.Close() // Close the client when the function returns (should not be needed, but just to be safe)

info, err := cli.Info(context.Background())
if err != nil {
log.Fatalf("Unable to get Docker info: %s", err)
}

// Check if Docker root directory contains '/var/snap/docker'
return strings.Contains(info.DockerRootDir, "/var/snap/docker")
}

func rootCmdRun(cmd *cobra.Command, _ []string) {
printLogo()
log.Debug("running in debug mode")
log.WithField("config_file", configPath).Info("loading configuration from file")

if isDockerSnap() {
log.Error("Docker Snap installation detected. Exiting...")
os.Exit(1)
}

if ok, _ := cmd.Flags().GetBool("ignore-certificate-errors"); ok {
log.Warn("running with --ignore-certificate-errors: TLS certificate host chains and name will not be verified")
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{
Expand Down

0 comments on commit 90f331d

Please sign in to comment.