Skip to content

fix(engine): use the configured socket for docker and docker compose too - #509

Draft
jordan8037310 wants to merge 1 commit into
lando:mainfrom
jordan8037310:fix/engine-socket-docker-host
Draft

jordan8037310 wants to merge 1 commit into
lando:mainfrom
jordan8037310:fix/engine-socket-docker-host

Conversation

@jordan8037310

Copy link
Copy Markdown

Refs lando/lando#3388.

The workaround in #3388 for running Lando on a non–Docker Desktop engine sets engineConfig.socketPath in ~/.lando/config.yml. It only half works, and this PR fixes the two reasons why.

1. Only dockerode uses the configured socket

  • engineConfig.socketPath is passed to dockerode, but the docker and docker compose subprocesses don't receive it. They follow whatever docker context is active.
  • build-config strips DOCKER_* from the environment, and get-engine-config only re-exports DOCKER_HOST for a TCP host.
  • With two engines installed, Lando can inspect containers on one engine while docker compose up creates them on the other.

Change: export DOCKER_HOST=unix://<socketPath> whenever the socket is not the default /var/run/docker.sock, on non-Windows platforms. With the default socket, nothing changes.

2. First-run autosetup resets the engine

  • After autosetup, hooks/lando-run-setup.js reloads config with build-config() and no options.
  • That drops every user config source, so engineConfig resets to the default socket, and DOCKER_HOST is stripped again.
  • The first lando start after setup therefore silently runs against /var/run/docker.sock.

Change: keep lando.config.engineConfig and re-run get-engine-config on it to re-export DOCKER_HOST, instead of rebuilding the engine config from defaults.

Validation

  • New specs:
    • test/get-engine-config.spec.js:
      • the default socket leaves DOCKER_HOST unset
      • a custom socketPath exports unix://…
      • a remote host still exports tcp://…
    • test/lando-run-setup.spec.js: a custom socket survives a setup run, in lando.config, in the rebuilt dockerode client, and in DOCKER_HOST.
  • Each spec fails on main. The run-setup spec was also mutation-checked against the old hook.
  • npm test on Node 20: lint clean, all unit specs pass.
  • Manual (macOS, Docker Desktop and OrbStack both installed):
    • Set engineConfig.socketPath to OrbStack's socket while the docker context still points at Docker Desktop.
    • Start from an empty Lando config dir so that autosetup runs.
    • lando start creates every container on OrbStack, checked with docker --context orbstack ps. Nothing appears on Docker Desktop.
    • Before this change, the same steps created the containers on Docker Desktop.

🤖 Generated with Claude Code

engineConfig.socketPath (the lando/lando#3388 workaround for non Docker
Desktop engines) only reached dockerode. build-config strips DOCKER_* and
get-engine-config re-exported DOCKER_HOST only for a tcp host, so the
docker and docker compose subprocesses followed the active docker context
and could run against a different engine.

- export DOCKER_HOST=unix://<socketPath> for any non-default socket
- keep the configured engineConfig after first-run autosetup instead of
  rebuilding it from defaults, which reset it to /var/run/docker.sock

Refs lando/lando#3388

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 15, 2026

Copy link
Copy Markdown

👷 Deploy request for lando-core pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5ca4d79

@github-actions

Copy link
Copy Markdown
Contributor

Privileged Leia tests skipped

The l337 and lando-v4 Leia suites verify authenticated SSH cloning and need the deploy key, so they do not run for fork pull requests.

After reviewing 5ca4d791f8656d6b8fb2bcb90a3f42ff52d387e0, a maintainer can run them against it with:

gh workflow run pr-core-tests.yml --repo lando/core -f pull_request=509 -f commit_sha=5ca4d791f8656d6b8fb2bcb90a3f42ff52d387e0

or from the workflow page using the same inputs. This comment updates when new commits are pushed and the dispatch only accepts the current head commit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant