0

我们在兰多和非兰多环境中使用我们的开发环境。有没有办法从类似的lando外部触发shell脚本docker exec

lando exec不能明显工作,它也不是标准命令的一部分,但也许 tehre 是一种创建它或将其添加为插件的方法?

4

2 回答 2

0

事实证明,lando 将这个构建作为工具 api的一部分。它不允许使用“自由式”命令,但您可以在.lando.yml.

我们案例中的一个简单示例:

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'

如果您需要root权限,只需添加user: root

在上面的示例中,您可以简单地调用

lando cex或者lando cim,触发自定义命令。

于 2021-07-15T13:22:45.140 回答
0

实际上有一种比使用工具 API 执行一次性命令更好的方法,它也更类似于 docker exec:

# Opens an interactive terminal inside container
lando ssh

# Runs a specified command inside container
lando ssh -c "ls -la /"

您可以更改目标服务/容器和运行命令的执行用户:

  --command, -c   Run a command in the service
  --service, -s   SSH into this service [default: "appserver"]
  --user, -u      Run as a specific user

在此处查看完整文档lando sshhttps ://docs.lando.dev/basics/ssh.html#usage

于 2021-08-31T10:03:53.673 回答