Reputation: 2193
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?
Upvotes: 0
Views: 1804
Reputation: 2193
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.
Upvotes: 3
Reputation: 955
There is actually a better way to execute one time commands than using the tooling API, that is also more similar to docker exec:
# Opens an interactive terminal inside container
lando ssh
# Runs a specified command inside container
lando ssh -c "ls -la /"
You can change the target service/container and the executing user which runs the command:
--command, -c Run a command in the service
--service, -s SSH into this service [default: "appserver"]
--user, -u Run as a specific user
See full documentation for lando ssh
here:
https://docs.lando.dev/basics/ssh.html#usage
Upvotes: 2