siderolabs / talos

Talos Linux is a modern Linux distribution built for Kubernetes.
https://www.talos.dev
Mozilla Public License 2.0
6.39k stars 514 forks source link

`talosctl` should honour Docker Contexts #7018

Open DWSR opened 1 year ago

DWSR commented 1 year ago

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

smira commented 1 year ago

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.

DmitriyMV commented 1 year ago

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.

James-Riordan commented 3 months ago

@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... :(

steverfrancis commented 3 months ago

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

MisterWS commented 2 weeks ago

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
mpartipilo commented 2 days ago

Little snippet I made today to make this work

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