Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run lando inside a Windows Docker image #43

Open
gpetrounrt opened this issue Sep 22, 2021 · 1 comment
Open

Cannot run lando inside a Windows Docker image #43

gpetrounrt opened this issue Sep 22, 2021 · 1 comment

Comments

@gpetrounrt
Copy link

gpetrounrt commented Sep 22, 2021

I am currently trying to run lando inside a Windows Docker image on Windows OS.
Specifically, I am using docker:20.10.8-windowsservercore-1809 from the official Docker in Docker website.

If I use the following Dockerfile, everything works when building by executing docker build -f Dockerfile -t lando-test .

FROM docker:20.10.8-windowsservercore-1809
SHELL ["powershell"]

ARG LANDO_VERSION=3.4.0

WORKDIR /app

RUN $landoUri = \"https://github.com/lando/cli/releases/download/v{0}/lando-win-x64-v{0}.exe\" -f $env:LANDO_VERSION; \
    $landoDestinationDirectory = ($pwd).Path + \"\\lando-cli\"; \
    $landoDestinationPath = $landoDestinationDirectory + \"\\lando.exe\"; \
    $env:Path += \";\" + $landoDestinationDirectory; \
    [Environment]::SetEnvironmentVariable('PATH', $env:Path, [EnvironmentVariableTarget]::Machine); \
    New-Item -Path $landoDestinationDirectory -ItemType Directory; \
    Invoke-WebRequest -Uri $landoUri -OutFile $landoDestinationPath

RUN lando version

However, when I try to run the image by executing
docker run -i --name lando-test -v //./pipe/docker_engine://./pipe/docker_engine lando-test I observe the following when executing commands inside the image:

docker run hello-world works just fine and gives the expected output.
lando version works just fine and gives the expected output.
lando init throws the following error:
Lando could not detect an installation of Docker, which is a required dependency

Looking at the daemon code and env code in GitHub, I see that the path to Docker is somehow hardcoded and does not match the path from the official Docker in Docker image which is C:\Program Files\docker\docker.exe. I guess that there are similar hardcoded paths in other places.

  1. Would it be possible to somehow add the ability to configure the paths in question?
  2. Is there already a way I could achieve this?
@gpetrounrt
Copy link
Author

gpetrounrt commented Sep 22, 2021

Apparently, I can use the following lines in the Dockerfile

RUN [Environment]::SetEnvironmentVariable('LANDO_DOCKER_BIN', \"C:\Program Files\docker\docker.exe\", [EnvironmentVariableTarget]::Machine)
RUN [Environment]::SetEnvironmentVariable('LANDO_DOCKER_BIN_DIR', \"C:\Program Files\docker\", [EnvironmentVariableTarget]::Machine)

I now see the following more mysterious error:

read ENOTSUP message=read ENOTSUP, stack=Error: read ENOTSUP
    at Pipe.onStreamRead (internal/stream_base_commons.js:209:20)
From previous event:
    at Landerode.listContainers (C:\snapshot\cli\node_modules\dockerode\lib\docker.js:419:12)
    at Landerode.list (C:\snapshot\cli\lib\docker.js)
    at C:\snapshot\cli\lib\engine.js
    at C:\snapshot\cli\lib\router.js
From previous event:
    at Object.eventWrapper (C:\snapshot\cli\lib\router.js)
    at Engine.engineCmd (C:\snapshot\cli\lib\engine.js)
    at Engine.list (C:\snapshot\cli\lib\engine.js)
    at AsyncEvents.<anonymous> (C:\snapshot\cli\plugins\lando-core\app.js)
    at AsyncEvents.handle (C:\snapshot\cli\lib\events.js)
    at C:\snapshot\cli\lib\events.js
    at processImmediate (internal/timers.js:464:21)
From previous event:
    at AsyncEvents.emit (C:\snapshot\cli\lib\events.js)
    at C:\snapshot\cli\lib\app.js
From previous event:
    at App.init (C:\snapshot\cli\lib\app.js)
    at initAndReport (C:\snapshot\cli\lib\app.js)
    at App.start (C:\snapshot\cli\lib\app.js)
    at Object.run (C:\snapshot\cli\plugins\lando-core\tasks\start.js)
From previous event:
    at C:\snapshot\cli\lib\cli.js
From previous event:
    at Object.handler (C:\snapshot\cli\lib\cli.js)
    at Object.runCommand (C:\snapshot\cli\node_modules\yargs\lib\command.js:238:44)
    at Object.parseArgs [as _parseArgs] (C:\snapshot\cli\node_modules\yargs\yargs.js:1063:30)
    at Function.get [as argv] (C:\snapshot\cli\node_modules\yargs\yargs.js:1004:21)
    at Cli.init (C:\snapshot\cli\lib\cli.js)
    at Cli.run (C:\snapshot\cli\lib\cli.js)
    at Object.<anonymous> (C:\snapshot\cli\bin\lando.js)
    at Module._compile (pkg/prelude/bootstrap.js:1751:22)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.runMain (pkg/prelude/bootstrap.js:1804:12)
    at internal/main/run_main_module.js:17:47, errno=-4049, code=ENOTSUP, syscall=read, __stackCleaned__=true

Perhaps there is another setting that I need to change?

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

No branches or pull requests

1 participant