How to run Lando in Pipelines
Asked by Gabriel Connolly:

I am trying to use [Lando](https://docs.lando.dev/) in my Bitbucket Pipelines to run my automated tests, but I am unable to get Lando to successfully start. The problem I'm wrestling with is that as a \`root\` user I have access to the Docker Daemon, but when I switch to the \`pipelines\` user to try and start Lando, I am presented with:  
\`\`\`

Unhandled rejection Error: Could not automatically start the Docker Daemon. Please manually start it to continue.

\`\`\`

The reason I am trying to run Lando as the \`pipelines\` user is Lando is specifically designed NOT to run as \`root\`: <https://github.com/lando/lando/issues/545>

I have tried adding the \`pipelines\` user to the \`docker\` user group per both the Docker and Lando documentation, but that does not seem to give me enough access to the Docker Daemon to the point where Lando will successfully start.

\* <https://docs.docker.com/engine/install/linux-postinstall/>  
\* <https://docs.lando.dev/basics/installation.html#linux>

My \`bitbucket-pipelines.yml\` file:

\`\`\`

```
image:
  name: libertyconcepts/bitbucket-pipelines-lando:1.0
  run-as-user: 1000

definitions:
  services:
    docker:
      memory: 3072

pipelines:
  branches:
    bitbucket-pipelines:
      - step:
          name: 'Deployment test on pipelines branch'
          script:
            - whoami
            - groups pipelines
            - docker info
            - docker version
            - lando version
          services:
            - docker
```

Has anyone been able to successfully implement Lando in Pipelines, and if so, what am I missing?


Answers:
author: Theodora Boudale
body: Hi [@Gabriel Connolly](/t5/user/viewprofilepage/user-id/773477) ,

I've done some investigation on this issue, using a bitbucket-pipelines.yml file similar to yours that also tries to start a Lando app. I've been able to reproduce this issue in Pipelines, and a colleague of mine has also reproduced this issue when [debugging it locally with Docker](https://support.atlassian.com/bitbucket-cloud/docs/debug-pipelines-locally-with-docker/).

If we try to run, for testing purposes, a '*docker run*' command in the build (the same build that is running as 'pipelines' user), the command is successful. This indicates that the build can connect to the docker(daemon) service when running as 'pipelines' user, and the issue doesn't seem to be related to the permissions of this user.

We also added flags for verbose output in both '*lando init* ' and '*lando start* ' commands. The verbose output of '*lando init* ' is showing that this command can detect the docker engine (the following is part of the output of '*lando init* ' with '*-vvv*' flag):

```
lando 03:33:03 VERBOSE ==> docker-engine exists: true 
lando 03:33:03 VERBOSE ==> docker-compose exists: true
```

However, based on the output of the '*lando start*' command that you also posted here

```
Unhandled rejection Error: Could not automatically start the Docker Daemon. Please manually start it to continue.
```

it looks that '*lando start*' is trying to start its own docker daemon instead of connecting to the existing docker (daemon) service.

It looks that the issue here has to do with the '*lando start*' command. Our suggestion would be to reach out to Lando support team to investigate further why 'lando start' is trying to start its own docker daemon instead of connecting to the existing docker (daemon) service. A little background that you can share with Lando support team is that Pipelines set up Docker daemon as a separate container and then attach the port and socket to the main build container, which allows docker client to connect to docker daemon.

If you need any further info from us, please feel free to let me know.

Kind regards,  
Theodora

comments: author: Gabriel Connolly
body: Thanks for the reply, [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) ! I'll see if I can work wit the Lando team/community to continue to troubleshoot this, and then bring my findings back here.


author: Theodora Boudale
body: You're very welcome Gabriel! Please feel free to post your findings here and also let me know if you need any further info.


Tags: bitbucket-pipelines

bitbucket-cloud

cloud