lando

Is there a command similar to docker exec in lando?


We are using our develpment environment in a lando and non lando context alike. Is there a way to trigger a shell script from outside lando similar to docker exec ?

lando exec does not work obvisously and it is also not part of the standard commands, but maybe tehre is a way to create it or add it as a plugin?


Solution

  • It turned out, that lando has this build in as part of the tooling api. It does not allow a "freestyle" command, but you can predefine any usefull shortcut you like in the .lando.yml.

    A simple example in our case:

    name: my_project
    recipe: drupal9
    config:
      database: mariadb
      drush: ^10
      php: '7.4'
      webroot: ./web
    tooling:
      cex:
        service: appserver
        description: Export the drupal config
        cmd: './scripts/cex.sh'
      cim:
        service: appserver
        description: Install dependencies and import the latest config.
        cmd: './scripts/cim.sh'
    

    If you need root permissions, just add user: root

    In the example above, you can simply call

    lando cex or lando cim, to trigger the custom commands.