Cloudron CLI
Section titled “Cloudron CLI”Overview
Section titled “Overview”The Cloudron CLI is a command line tool for building and installing custom apps.
All CLI commands operate on apps, not the server. For example, cloudron restart and cloudron uninstall
operate on an app, not the server.
Installing
Section titled “Installing”The CLI is distributed via npm. Install on Linux/Mac:
sudo npm install -g cloudronThe CLI is not tested on Windows but works with varying success. Windows users should use a Linux VM instead.
Updating
Section titled “Updating”Update the CLI:
npm install -g cloudron@<version>The version number can be found here.
Global options
Section titled “Global options”A small set of options applies to every command and must appear before the subcommand:
--server <server>- Cloudron server domain--token <token>- API token (see CI/CD)--allow-selfsigned- accept a self-signed SSL certificate--accept-selfsigned- alias of--allow-selfsigned--no-wait- return immediately instead of waiting for the operation to finish
Example:
cloudron --server my.example.com --token 001e7174c4cbad2272 update --app blog.example.com --image username/image:tagA global option placed after the subcommand is rejected as an unknown argument.
Authenticate with your server:
cloudron login my.example.comA successful login stores the authentication token in ~/.cloudron.json.
Listing apps
Section titled “Listing apps”Display installed apps:
cloudron listThe Id is the unique app instance id. Location is the domain where the app is
installed. Use either field as the argument to --app.
Viewing logs
Section titled “Viewing logs”View app logs:
cloudron logs --app blog.example.comcloudron logs --app 52aae895-5b7d-4625-8d4c-52980248ac21Pass -f to follow the logs. Not all apps log to stdout/stderr. Check the file system for logs:
cloudron exec --app blog.example.com # shell into the app's file system# tail -f /run/wordpress/wp-debug.log # note that log file path and name is app-specificPushing a file
Section titled “Pushing a file”Push a local file to the app’s file system:
cloudron push --app blog.example.com dump.sql /tmp/dump.sqlcloudron push --app blog.example.com dump.sql /tmp/ # same as above. trailing slash is requiredPush a directory recursively:
cloudron push --app blog.example.com files /tmpSyncing files and directories
Section titled “Syncing files and directories”Use cloudron sync push and cloudron sync pull to transfer only changed files
(size + mtime comparison), similar to rsync.
cloudron sync push --app blog.example.com ./local/ /app/data # upload contents of local into /app/datacloudron sync push --app blog.example.com ./local /app/data # upload local dir itself into /app/data/localcloudron sync push --app blog.example.com file.txt /app/data # upload a single filecloudron sync pull --app blog.example.com /app/data/ ./local # download contents of /app/data into ./localcloudron sync pull --app blog.example.com /app/data ./local # download /app/data dir itself into ./local/dataA trailing slash on the source syncs its contents; without it, the directory itself is placed inside the destination (same convention as rsync).
Options:
--deleteremoves files that exist only at the destination side.--forceremoves files blocking directory creation at the destination.
For directory workflows, prefer cloudron sync over cloudron push/pull.
Use cloudron push/pull for simple one-off file copies or stdin/stdout style transfers.
Pulling a file
Section titled “Pulling a file”Pull a file from the app’s file system:
cloudron pull --app blog.example.com /app/code/wp-includes/load.php . # pulls file to current dirPull a directory:
cloudron pull --app blog.example.com /app/code/ . # pulls content of code to current dircloudron pull --app blog.example.com /app/code/ code_backup # pulls content of code to ./code_backupEnvironment variables
Section titled “Environment variables”Set environment variable(s):
cloudron env set --app blog.example.com RETRY_INTERVAL=4000 RETRY_TIMEOUT=12minUnset an environment variable:
cloudron env unset --app blog.example.com RETRY_INTERVALList environment variables:
cloudron env list --app blog.example.comGet a single environment variable:
cloudron env get --app blog.example.com RETRY_INTERVALApp shell
Section titled “App shell”Open a shell to browse the container filesystem:
cloudron exec --app blog.example.comApart from 3 special directories - /app/data, /run and /tmp, the file system is read-only. Changes to /run and /tmp are lost across restarts. These directories are also cleaned up periodically.
Execute a command
Section titled “Execute a command”Execute arbitrary commands in the context of an app:
cloudron exec --app blog.example.com# ls # list files in the app's current dir# mysql --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} --host=${MYSQL_HOST} ${MYSQL_DATABASE} # connect to app's MySQLPass a command with options using -- to indicate end of arguments:
cloudron exec --app blog.example.com -- ls -lIf the command has environment variables, execute it using a shell:
cloudron exec --app blog.example.com -- bash -c 'mysql --user=${CLOUDRON_MYSQL_USERNAME} --password=${CLOUDRON_MYSQL_PASSWORD} --host=${CLOUDRON_MYSQL_HOST} ${CLOUDRON_MYSQL_DATABASE} -e "SHOW TABLES"';The --server and --token global options integrate the CLI into a CI/CD pipeline. Get tokens at https://my.example.com/#/system-settings. Both options must appear before the subcommand:
cloudron --server my.example.com --token 001e7174c4cbad2272 update --app blog.example.com --image username/image:tag