Skip to content

Instantly share code, notes, and snippets.

@castrojo
Created August 13, 2025 00:24
Show Gist options
  • Save castrojo/d3f186a4ca916050ff7759031c2b5bde to your computer and use it in GitHub Desktop.
Save castrojo/d3f186a4ca916050ff7759031c2b5bde to your computer and use it in GitHub Desktop.
You can automate this with a shell script using the distrobox CLI. Here’s a template:
```sh
#!/bin/sh
# Set your container name and the script you want to run inside the container
CONTAINER_NAME="mycontainer"
SCRIPT_PATH="/path/in/container/myscript.sh"
# If your script is on the host and you want to copy it in, use:
# distrobox enter --name "$CONTAINER_NAME" -- cp /path/on/host/myscript.sh "$SCRIPT_PATH"
# Start the container and run the script inside it
distrobox enter --name "$CONTAINER_NAME" -- "$SCRIPT_PATH"
```
This will enter the specified Distrobox container and execute the script inside it. If you want to run the script non-interactively (no terminal), add the `--no-tty` flag. If your container takes a moment to start, you might need a short `sleep` before running commands after creation [reference](https://distrobox.it/usage/distrobox-enter).
You can pass arguments to your script by adding them after the script path, like `-- "$SCRIPT_PATH" arg1 arg2`.
Make sure the script you want to run is present and executable inside the container. If not, copy it in as shown in the commented line above.
For more details and examples, see the official docs [here](https://distrobox.it/usage/distrobox-enter) and a user example [here](https://github.com/ublue-os/boxkit/issues/34#issuecomment-1516161963).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment