talos icon indicating copy to clipboard operation
talos copied to clipboard

`talosctl` should honour Docker Contexts

Open DWSR opened this issue 2 years ago • 5 comments

Bug Report

Description

talosctl does not honour Docker contexts. For example, if the Docker endpoint is non-standard (e.g. when using Colima), then talosctl fails unless DOCKER_ENDPOINT is set.

Logs

$ talosctl cluster create

validating CIDR and reserving IPs
generating PKI and tokens
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Environment

  • Talos version:
Client:
	Tag:         v1.3.6
	SHA:         5b6176d8
	Built:
	Go version:  go1.19.7
	OS/Arch:     darwin/amd64
Server:
	NODE:        10.5.0.3
	Tag:         v1.3.6
	SHA:         5b6176d8
	Built:
	Go version:  go1.19.7
	OS/Arch:     linux/arm64
	Enabled:     RBAC
	NODE:        10.5.0.2
	Tag:         v1.3.6
	SHA:         5b6176d8
	Built:
	Go version:  go1.19.7
	OS/Arch:     linux/arm64
	Enabled:     RBAC
  • Kubernetes version: N/A
  • Platform: Docker

DWSR avatar Mar 28 '23 19:03 DWSR

talosctl is using docker client library, so it should work pretty much same way as docker CLI.

I'm not sure if contexts are available in the docker client library, but if they are, it should be an easy fix.

smira avatar Mar 28 '23 19:03 smira

As far as I can tell github.com/docker/docker/client have nothing related to contexts. docker context rely on entire cli implementation, which I don't think we should pull as a dependency. We could copy only relevant parts, but that will require a lot of effort now and in the future to support our fork. Other than that, implementation should be relatively straightforward.

PR's are welcome anyway tho.

DmitriyMV avatar Mar 29 '23 05:03 DmitriyMV

@DWSR can you please share with me where you set DOCKER_ENDPOINT? I'm in the same boat of using Colima instead of Docker Desktop but am stuck at the error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? and am looking for next steps.

I tried export DOCKER_ENDPOINT="$HOME/.colima/docker.sock" but it doesn't work for me... :(

James-Riordan avatar May 13 '24 19:05 James-Riordan

Maybe try ln -s -f /Users/<user>/.docker/run/docker.sock /var/run/docker.sock as per https://docs.docker.com/desktop/mac/permission-requirements/#installing-symlinks

steverfrancis avatar May 13 '24 20:05 steverfrancis

Instead of adding symlinks, setting the standard DOCKER_HOST environment variable (not DOCKER_ENDPOINT as suggested above) works:

DOCKER_HOST=unix:///$HOME/.colima/default/docker.sock talosctl cluster create

MisterWS avatar Aug 18 '24 16:08 MisterWS

Little snippet I made today to make this work

export DOCKER_HOST=$(docker context inspect $(docker context show) --format '{{ .Endpoints.docker.Host }}')

mpartipilo avatar Sep 05 '24 12:09 mpartipilo

Since the workaround is quite simple, and changing the behavior will require a lot of new code, which is not going to be used frequently, I think it's safe to say this is not something we will do in the foreseeable future.

DmitriyMV avatar Oct 21 '24 17:10 DmitriyMV