Created
April 17, 2025 14:27
-
-
Save jweslley/fb69be25643258a29f30726960cca2d9 to your computer and use it in GitHub Desktop.
Kamal cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kamal commands cheat sheet | |
# The init command is used to create the config and secrets files once after Kamal is added to the app. | |
$ kamal init | |
# Install Docker on all target hosts | |
$ kamal server | |
# Aliases | |
# Kamal defines `kamal shell` out of the box, I usually add `kamal console` to quickly access the Rails console. | |
$ kamal shell [-d production] | |
# app exec -i --reuse "bin/rails console" | |
$ kamal console [-d production] | |
# Deploy app [to the staging environment] | |
$ kamal deploy [-d staging] | |
# Rollback app [to the VERSION] [in the staging environment] | |
$ kamal rollback [VERSION] [-d staging] | |
# Building images | |
# Most of the time you won't use the `kamal build` command directly, | |
# since it primarily used by `kamal deploy` and `kamal redeploy`. | |
# However, you can also use it to build the app image without pushing it, which is useful for testing. | |
$ kamal build dev | |
# Below are several commands to read the logs of the app and its accessories. | |
$ kamal app logs [--roles=web -n 100 -f] | |
$ kamal app logs [--primary -n 100 -f] | |
$ kamal app logs [--hosts=<ip_address>> -n 100 -f] | |
$ kamal audit | |
# Show logs for the PgHero accessory [for the staging environment] | |
$ kamal accessory logs pghero [-d staging] | |
# Show logs for the proxy server [for the staging environment] | |
$ kamal proxy logs [-d staging] | |
# Show combined config (including secrets) [for the staging environment]. Can be useful to debug and in case you forgot your server ip-address. | |
$ kamal config [-d staging] | |
# Print secrets to stdout [for the staging environment] | |
$ kamal secrets print [-d staging] | |
# Show details about all containers grouped by role [for the staging environment] | |
$ kamal details [-d staging] | |
# Show details only about the app containers [for the staging environment], [for the web role] | |
$ kamal app details [-d staging] [--roles=web] | |
# Show details only about the PgHero accessory containers [for the staging environment] | |
$ kamal accessory details pghero -d staging |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment