Dockerize any project and deploy it to your servers — with pure Bash.
Yoda turns a git repository into a Docker setup that you can run on your machine and ship to one server or many over SSH. It adds a docker/ folder to your project, builds your images, writes one Compose file per environment, starts containers in the order you choose, and deploys to all servers in parallel. One command rolls back.
There is no agent, no daemon and no control plane. Yoda is a set of Bash scripts on top of git, ssh and docker compose, and you can read all of it in an afternoon.
Contents: Why Yoda · How it works · Installation · Quick start · Deploy to servers · Configuration · CLI reference · Recipes · Troubleshooting · Security notes · Development
- Few dependencies. You need Bash, git, SSH and Docker with the Compose plugin. No agent or daemon runs on your servers.
- Environments built in. Use
dev,productionor any other name. Each one can have its own env file and its own Compose overrides. - Many servers in parallel. One
Envfilemaps hosts to environments and stacks.yoda deployruns on every node at once and reports each result. - Rollback built in. Each deploy records its revision on the server.
yoda rollbackredeploys the one before it. - Ordered starts. A
Startfilecan stop services first, start others in chunks, and wait for one-shot jobs such as migrations. - Scale from one template.
web=4creates four containers from one definition. - Hooks at every stage. Put an executable
build,compose,start,stop,destroyordeployscript indocker/to wrap or replace that step. - Tested. CI runs ShellCheck and a Bats test suite on Linux and macOS.
Yoda fits well when:
- you run a few VMs or bare-metal servers and want repeatable, git-driven deploys without Kubernetes or a PaaS;
- you already work with Docker Compose and want environments, scaling and multi-host deploys on top of it;
- you want a deploy tool small enough to read and change yourself.
Choose something else if you need:
- scheduling across a cluster, self-healing or autoscaling (Kubernetes, Nomad, Swarm);
- zero-downtime rolling deploys out of the box. Yoda recreates changed containers in place. You can replace containers one by one by hand;
- load balancing, TLS termination or secret management. Bring your own tools for these.
flowchart LR
cli["Your machine: yoda deploy --env=production"] -->|"SSH, agent forwarded"| s1["box@server-1"]
cli -->|"SSH, agent forwarded"| s2["box@server-2"]
git[("Your git remote")] -.->|"fetch branch or --rev"| s1
git -.->|"fetch branch or --rev"| s2
s1 --> up1["yoda start: build, compose, up"]
s2 --> up2["yoda start: build, compose, up"]
On your machine, yoda start does three things:
- It writes
docker/docker-compose.<env>.ymlfrom your container templates. - It builds the images listed in
Buildfile, tagged with the current commit. - It runs
docker compose up.
yoda deploy runs that same yoda start on each server, inside a fresh checkout of your repository. FLOW.md describes each stage in detail.
| Requirement | Version | Notes |
|---|---|---|
| Bash | 4.0+ | macOS ships Bash 3.2: brew install bash |
| Docker Engine | API 1.41+ (Docker 20.10+) | |
| Docker Compose plugin | v2 (docker compose) |
Yoda does not use the old docker-compose binary |
| Git | 2.22+ | |
| GNU sed | — | macOS: brew install gnu-sed |
make check checks the versions of Bash, Docker, Compose and Git. Yoda refuses to run as root. Use a regular user that can talk to Docker.
git clone https://github.com/Muvon/yoda.git
cd yoda && make check && sudo make installmake install creates a symlink from /usr/local/bin/yoda to yoda in the clone. To update Yoda, run git pull in the clone. To uninstall, remove the symlink and the clone.
brew install muvon/tap/yodaHomebrew installs the release tarball, not a git checkout. Local work and deploys both work. Only automatic switching to a project's pinned Yoda version needs a git clone. Without one, Yoda warns and runs the installed version.
Check the install:
yoda version # prints the installed version, e.g. Yoda version: 2.6.0yoda init writes the current Yoda version into docker/.yodarc. If you run a different Yoda version in that project, Yoda checks out the project's version tag in its own git clone and runs the command again. If it cannot switch, for example with a Homebrew install or a missing tag, it prints a warning and continues with the installed version. Run yoda upgrade in the dev environment to move a project to the version you have installed. On servers, deploys use this same mechanism to run the project's pinned version.
This example serves your project's files with Python. It takes about two minutes and needs only Docker.
1. Create the skeleton. Run Yoda from your project root, which should be a git repository:
yoda init # creates docker/
yoda add web # creates docker/containers/web/ and adds web to the dev environment2. Describe the image in docker/images/Dockerfile-base:
FROM python:3.12-alpine
COPY . /src3. Tell the container what to run in docker/containers/web/entrypoint:
#!/usr/bin/env sh
exec python -m http.server 80884. Publish a port. Append these lines to docker/containers/web/container.yml:
ports:
- "8088:8088"5. Start it:
yoda start --wait # build the image, write the Compose file, start web
curl localhost:8088 # lists your project files
yoda status # docker compose ps
yoda log -f web # follow the logs
yoda destroy # remove the containers, networks and volumesImages are tagged with the short commit hash, or latest before your first commit. If the tag already exists, Yoda skips the build. After you change code without making a new commit, run yoda start --rebuild.
Add your hosts to docker/Envfile:
[email protected]: production
production: web=2 worker
dev: web workerA server needs Docker with the Compose plugin, git and Bash 4+. The SSH user from the Envfile must be allowed to run Docker, and it must not be root.
On a fresh Rocky Linux 9/10, CentOS Stream 9 or CentOS 8 server, Yoda can do this for you. You need root SSH access with a key:
cp ~/.ssh/id_ed25519.pub docker/.ssh/authorized_keys # docker/.ssh is git-ignored
yoda setup --env=productionThis changes system configuration and reboots the server. Read what setup changes before you run it. On other distributions, prepare the servers by hand.
Before you deploy, push your branch. Each server checks out origin/<branch>, so commits that are only on your machine are not deployed. Your SSH key must be loaded in your agent (ssh-add), because the servers use it to clone your repository.
yoda deploy --env=productionYoda deploys to every matching node in parallel and shows a live status for each one:
Nodes: 2
Logs: /path/to/project/docker/log
Started: Sat Oct 24 07:20:40 UTC 2026
Elapsed: 41 s
[email protected] – succeed
[email protected] – failed
Finished: Sat Oct 24 07:21:21 UTC 2026
[email protected] log:
...last 5 lines of docker/log/box_203.0.113.11.log...
The command exits with 0 only if every node succeeds. This makes it safe to use in CI.
On each server, a deploy does the following:
- On the first deploy, it clones Yoda into
~/.yodaand your project into~/.deploy/<project>. - It fetches, checks out the branch and runs
git reset --hard origin/<branch>. With--rev, it checks out that revision instead. - It runs
git clean -fdx, which removes every file that git does not track. - It runs
ENV=<env> STACK=<stack> yoda start. - It appends the deployed revision to
~/.deploy/<project>.revision.
| Command | Deploys to |
|---|---|
yoda deploy --env=production |
every host in production, all stacks included |
yoda deploy --env=production --stack=front |
only hosts in production.front |
yoda deploy --host=203.0.113.10 |
hosts that match the regular expression |
yoda deploy --env=production --rev=2.1.0 |
a specific tag or commit |
yoda deploy --env=production --branch=release |
the head of another branch |
yoda deploy --env=production --args="WORKERS=8" |
as usual, and passes WORKERS=8 to yoda start on each node |
yoda rollback --env=production # the previous revision on every node
yoda rollback --env=production --rev=abc1234 # a specific revisionWithout --rev, Yoda reads the second-to-last entry of each server's revision file. All target servers must agree on that revision. If they do not, Yoda lists each host's revision and exits with code 1. In that case, pass --rev. Automatic rollback needs at least two recorded deploys. With fewer, it exits with No revisions found to rollback.
A rollback redeploys the code at that revision. It does not undo database migrations or changes inside volumes.
yoda init creates the files below. To use a different folder name, pass it to yoda init, for example yoda init deploy.
your-project/
├── .dockerignore # created empty by yoda init
└── docker/
├── .yodarc # pinned version and built-in variables; managed by Yoda
├── env.sh # your variables, for every environment
├── env.production.sh # optional, per environment
├── Buildfile # which images to build, and how
├── Envfile # hosts → environments → containers
├── Startfile # optional start order
├── images/
│ └── Dockerfile-base # one Dockerfile per image: Dockerfile-<name>
├── containers/
│ ├── compose.yml # shared top-level Compose: networks, volumes, anchors
│ └── web/
│ ├── container.yml # Compose service body
│ ├── container.production.yml # optional per-environment override
│ └── entrypoint
├── .ssh/authorized_keys # for yoda setup (git-ignored)
├── log/ # deploy and setup logs (git-ignored)
└── docker-compose.dev.yml # written on every run (git-ignored)
Yoda loads these files on every command, in this order. Later files override earlier ones.
.yodarc, which holds the built-in variablesenv.shenv.<ENV>.sh, for exampleenv.production.shenv.<ENV>.<STACK>.sh, for exampleenv.production.front.sh
These are plain Bash files. Export each variable that Buildfile, Dockerfiles, *.yoda templates or Compose need to see. A plain assignment stays inside the Yoda process.
export APP_PORT=${APP_PORT:-8088} # deploy --args="APP_PORT=9000" can still override it
export REGISTRY_URL=registry.example.com/acmeBuilt-in variables:
| Variable | Value |
|---|---|
ENV |
Current environment. Defaults to dev. Set it per call: ENV=production yoda start |
STACK |
Namespace from Envfile (production.<stack>). Deploy sets it. |
REVISION |
Image tag: the 7-character commit hash, or latest before the first commit. deploy --rev sets it. |
REVISION_TAG |
The git tag on HEAD, if there is one |
GIT_URL, GIT_BRANCH |
URL of the origin remote and the current branch |
SOURCE_PATH, DOCKER_ROOT |
Project root and the docker/ folder |
COMPOSE_PROJECT_NAME |
Project directory name when you ran yoda init. Prefixes container names. |
COMPOSE_FILE |
The Compose file Yoda writes: docker/docker-compose.<ENV>.yml |
REGISTRY_URL |
Empty by default. See Use a registry. |
STOP_WAIT_TIMEOUT |
Seconds to wait for a container to stop before it is killed. Empty means each service's stop_grace_period applies. |
Write one line per image: a name, then the arguments for docker build. Yoda expands variables and reads the image name from -t.
base: -t ${COMPOSE_PROJECT_NAME}/base:${REVISION}
nginx[docker/images/nginx]: -t ${COMPOSE_PROJECT_NAME}/nginx:${REVISION} --build-arg NGINX_VERSION=1.27- Each image is built from
docker/images/Dockerfile-<name>. Before the build, Yoda replaces every%{VAR}in that Dockerfile with the variable's value. - The build context is the project root. Use
name[path]:to set a different one. - Builds use
--network host. If the tag already exists, Yoda skips the build unless you pass--rebuild. - In a
container.yml, writeimage: baseto use the image thatBuildfiledefines asbase.
Each container lives in docker/containers/<name>/. yoda add <name> creates these files:
| File | Purpose |
|---|---|
container.yml |
The body of a Compose service, without the service name |
container.<env>.yml |
Optional override. Each top-level key in it replaces the whole key from container.yml in that environment. |
entrypoint |
The executable that the container runs |
For every container, Yoda adds these settings to the generated Compose file:
container_name: <project>.<name>. Yoda manages this setting, so do not set it yourself.hostname: <name>, unless you sethostnameyourself.- The
networksandrestartdefaults for the current environment, unless you setnetworks,network_modeorrestartyourself.
The defaults come from YAML anchors in containers/compose.yml:
| Environment | Network | Restart |
|---|---|---|
dev |
default bridge network |
'no' |
production |
network_mode: host |
always |
Important
Every environment you use needs its own anchors in containers/compose.yml. For a staging environment, add default_staging_networks and default_staging_restart, or Compose fails with unknown anchor. See Add an environment.
Variables in templates. Yoda turns %{VAR} in a container.yml into ${VAR}. Compose then fills in the value when the container starts. Names may contain only uppercase letters and _.
environment:
APP_ENV: %{ENV}Nested containers. yoda add worker.mail creates containers/worker/mail/ and the container worker.mail. You can also write a single file at containers/worker/mail.yml. A nested container inherits everything from containers/worker/container.yml and overrides only the keys it sets.
Rendered config files. Before each build, Yoda renders every *.yoda file under docker/ to the same path without the .yoda suffix, with %{VAR} replaced. For example, nginx.conf.yoda becomes nginx.conf. Add the rendered files to .gitignore.
The Envfile maps servers to environments, and environments to containers:
[email protected]: production.front
[email protected]: production.back
production.front: web=2
production.back:
- worker
- worker.mail=2
dev: web worker- Hosts:
user@host: <env>oruser@host: <env>.<stack>. Deploy connects as that user. - Containers: list them on one line, or as a YAML list under the environment.
- Scaling:
web=2creates the containersweb.0andweb.1. A single container has no suffix. - Stacks: the part after the dot lets servers in one environment run different containers.
--env=productiontargets every stack, and--stack=fronttargets one.
The Startfile sets the start order for an environment, or for one stack of it:
production:
stop: worker
flow: migrate web=2
wait: migrate- stop: services to stop before anything else starts. Here, workers stop so they do not run old code during a migration.
- flow: the start order.
web=2starts thewebcontainers two at a time. - wait: services from
flowthat must exit with code0before Yoda continues. If one fails, Yoda prints its logs and stops the start. - Services that are not in
flowstart afterwards, all together.
Some rules apply:
- Sections. For a stack, Yoda uses the
production.front:section if it exists, and otherwise the sharedproduction:section. - Shared sections. A shared section applies to each stack only for the services that stack runs. Yoda prints
Skipping service …for the others. - Unknown services. A service that doesn't exist stops the start with
No service '<name>' of section '<key>' in pool of services. This catches typos. - Chunks. In
flow,web=2sets the chunk size. It does not need to match the count inEnvfile. - One-shot services in production. Set
restart: "no"on the services inwait. Otherwise thealwaysrestart default reruns a finished migration. - Skipping the Startfile.
yoda start --forceignores it.
To replace a built-in step, add an executable file named build, compose, start, stop, destroy or deploy to docker/. Yoda runs your script with all Yoda variables in its environment. build, start, stop and deploy hooks also get the command's arguments. To run the built-in step from your script, call yoda <command> or exec yoda <command>. Hooks live in your repository, so a start hook also runs on every server during a deploy.
#!/usr/bin/env bash
# docker/deploy: run the tests, then the built-in deploy
set -e
make test
yoda deploy "$@"yoda command [options] [arguments]| Command | Description |
|---|---|
| version | Display version of Yoda |
| help | Display help information |
| init | Prepare deployment folder in project |
| upgrade | Upgrade initialized Yoda in project to a new version |
| add | Add new container skeleton to project |
| delete | Delete existing container from project |
| build | Build images for current project |
| compose | Display generated compose file for current environment |
| start | Start all services for current project |
| stop | Stop all services for current project |
| status | Display current status of services |
| log | Show log for a given container |
| logs | Show log for all containers |
| exec | Execute a command in a container |
| enter | Enter a container with autodetected shell: zsh, bash or sh |
| setup | Prepare a server for use with Yoda deployment |
| deploy | Deploy project on one or all nodes |
| rollback | Rollback project on one or all nodes to previous revision |
| destroy | Remove services, networks and volumes created by start |
Run every command from the project root. The current environment comes from ENV and defaults to dev. Options that take a value use the form --name=value. upgrade, add and delete work only in the dev environment.
Display the Yoda version. Inside a project, this is the version pinned in .yodarc.
Display help information.
Create the docker/ skeleton in the current project.
| Argument | Description | Default |
|---|---|---|
| folder | Name of the folder to create | docker |
Run the upgrade scripts between the project's pinned version and the installed version, then update .yodarc.
Create a skeleton for one or more containers and add them to the dev line of Envfile.
Delete one or more containers and remove them from Envfile.
Build images from Buildfile. Pass image names to build only those images.
| Option | Description | Default |
|---|---|---|
| --rebuild | Build even if the image tag already exists | off |
| --no-cache | Build without the Docker layer cache | off |
| --push | Tag and push the built images to REGISTRY_URL, if it is set |
off |
Print the generated Compose file for the current environment to stdout. This is a safe way to check what start will run: ENV=production yoda compose.
| Argument | Description | Default |
|---|---|---|
| COMPOSE_SCRIPT | An executable that changes each container template. It reads the template from stdin, gets --name=<container> and --sequence=<index> as arguments, and prints the result. Yoda exits with an error if the script is missing or not executable. |
- |
Write the Compose file, build or pull the images, then start every container or only the ones you name. Put options before container names.
| Option | Description | Default |
|---|---|---|
| --rebuild | Rebuild images even if they exist with this revision | off |
| --no-cache | Build without the Docker layer cache | off |
| --recreate | Recreate containers even if their configuration did not change | off |
| --force | Ignore the Startfile | off |
| --keep-orphans | Do not remove containers that are no longer in the Compose file (drops --remove-orphans) |
off |
| --wait | Return when the started containers are running and healthy. Fail if one exits or becomes unhealthy (Compose up --wait). |
off |
If REGISTRY_URL is set, Yoda pulls the images instead of building them, unless you pass --rebuild.
Stop every container, or only the ones you name. STOP_WAIT_TIMEOUT sets how many seconds a container gets to exit before it is killed. When it is empty, the default for new projects, each service's stop_grace_period applies (Compose default: 10 s). Example: STOP_WAIT_TIMEOUT=60 yoda stop app.
Show the state of the services (docker compose ps).
Show logs. Accepts the options of docker compose logs, for example -f, --tail=100, --timestamps and --no-color.
Same as yoda log.
Run a command in a running container (docker compose exec), for example yoda exec web ls -la.
Open an interactive shell in a container. Yoda uses zsh, bash or sh, whichever it finds first.
Prepare fresh servers for deployment. This needs root SSH access with a key and docker/.ssh/authorized_keys. It supports Rocky Linux 9/10, CentOS Stream 9 and CentOS 8. Read the security notes first.
| Option | Description | Default |
|---|---|---|
| --host | Set up hosts from Envfile that match this regular expression |
- |
| --env | Set up every host in this environment | - |
Deploy to one node or to the whole cluster in parallel. Exits with 0 on success and 1 if any node fails. Logs go to docker/log/<user>_<host>.log.
| Option | Description | Default |
|---|---|---|
| --host | Deploy to hosts from Envfile that match this regular expression |
- |
| --env | Deploy to every host in this environment, all stacks included | - |
| --stack | Deploy only to this stack of the environment | - |
| --rev | Git revision (commit or tag) to check out and deploy. Also used as REVISION. |
branch head |
| --branch | Branch to deploy | current branch |
| --args | Environment variables to pass to yoda start on each node. Only their names are printed. |
- |
| --force | Pass --force to yoda start |
off |
Redeploy the previous revision. Accepts the same options as deploy. See Rollback.
Run docker compose down --rmi local --volumes. This removes the project's containers and networks, the volumes declared in the Compose file, and images that have no custom tag.
Caution
destroy deletes volumes, and their data is lost.
# docker/Envfile
production: migrate web worker# docker/Startfile
production:
stop: worker
flow: migrate web
wait: migrate# docker/containers/migrate/container.yml
image: base
working_dir: /src
command: ["./bin/migrate"]
restart: "no"The workers stop, the migration runs to completion, web starts, and then the workers start again.
Scale web to web=2 in Envfile. The running web container is now an orphan, because the new containers are web.0 and web.1. Start a new container and keep the old one serving:
yoda start --keep-orphans web.0When you are ready, stop the old container with docker stop <project>.web. Then run a plain yoda start to remove it and start web.1.
Add a healthcheck to the service:
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8088/health"]
interval: 5s
retries: 10yoda start --wait then fails if a container exits or becomes unhealthy. yoda deploy does not pass --wait to the servers. To use it on every start, locally and during deploys, add a start hook:
#!/usr/bin/env bash
# docker/start: always wait for healthy containers
yoda start --wait "$@"A node whose containers do not become healthy is then reported as failed.
Add anchors for the new environment to docker/containers/compose.yml:
x-staging-networks: &default_staging_networks
networks:
- default
x-staging-restart: &default_staging_restart
restart: unless-stoppedThen list its containers in Envfile (staging: web worker), and optionally create env.staging.sh. Check the result with ENV=staging yoda compose.
Set REGISTRY_URL in env.sh. CI builds and pushes the images, and the servers only pull them:
yoda build --push # in CI
yoda deploy --env=production # each server runs yoda start, which pulls instead of building| Message or symptom | Cause and fix |
|---|---|
Yoda is not inited. Run 'yoda init' first. |
Run Yoda from the project root. It looks for */.yodarc one level down. |
You are not allowed to run Yoda as root. |
Use a regular user in the docker group. |
Build is already in progress. |
An earlier build was interrupted. Delete docker/.build.lock. |
| Code changes do not show up | The image tag is the commit, and the image already exists. Commit, or run yoda start --rebuild. |
unknown anchor 'default_<env>_networks' referenced |
Add the anchors for this environment to containers/compose.yml. See Add an environment. |
No services to build. First you should add container. |
The current ENV has no containers in Envfile. |
… is found but its not executable |
Run chmod +x on the hook or compose script. |
Cant define environment for host |
The host is not listed in Envfile. |
Found inconsistency in revisions on all servers |
The nodes run different revisions. Pass --rev to rollback. |
| A deploy failed | Read docker/log/<user>_<host>.log on your machine. |
Permission denied when binding a port below 1024 |
The default container.yml drops all capabilities. Add cap_add: [NET_BIND_SERVICE] or use a higher port. |
yoda setupchanges the whole server. It connects asrootwith your key. It installs Docker, firewalld, tuned, chrony and git-secret. It creates two users with yourauthorized_keys:admin, which gets passwordlesssudo, andbox, which joins thedockergroup. It replaces/etc/ssh/sshd_config, which disables root and password logins, and/etc/sysctl.conf. It writes/etc/docker/daemon.jsonwith"iptables": false,live-restoreand log rotation. Then it reboots the server after one minute. Run it only on fresh servers, and readserver/first. Because root login is disabled afterwards, you cannot run setup on the same host twice.- The
dockergroup is equivalent to root on that host. - Deploys forward your SSH agent (
ssh -A), so servers can clone your repository with your key. While a deploy runs, anyone with root on that server can use your agent. Deploy only to servers you trust, or give your repository a dedicated deploy key. - Host keys are trusted on first use. If a host is not in your
known_hosts, Yoda adds it withssh-keyscan. To pin the keys, add the hosts toknown_hostsyourself first. - Deploys wipe the server checkout.
git reset --hardandgit clean -fdxrun in~/.deploy/<project>. Keep state in volumes, not in the checkout. --argsvalues are hidden in the local output, but they are part of the command that runs on the server.- Keep secrets out of images.
docker/.sshanddocker/logare git-ignored. However,COPY . /srcstill copies them into the image unless the.dockerignorein the project root lists them.
- A project can have several images. Each one has a Dockerfile named
docker/images/Dockerfile-<name>. - Several containers can share one image.
- Each container has its own folder in
docker/containers/, and one template can be scaled N times. Envfileis the source of truth: which containers run in which environment, and which servers run which environment.- Configuration is plain Bash variables in
env.sh, which every stage can use. - Every stage can be replaced by your own executable script, in any language.
make check # verify prerequisites
make lint # shellcheck -S style + bash -n on all scripts
make test # bats test suite (tests/)CI runs lint on Ubuntu and the Bats suite on Ubuntu and macOS. Commit messages follow Conventional Commits.
The version lives in VERSION and follows SemVer. Releases are cut with octocode, which picks the bump from the Conventional Commits since the last tag:
make release # bump VERSION, write CHANGES.md, commit and tag
git push origin master --follow-tags # CI publishes the releaseThe Release workflow checks that the tag matches VERSION, creates the GitHub release with the tag's changelog and updates the Homebrew formula. Add an upgrades/version-X.Y.Z script only when projects need a migration or a notice on yoda upgrade.
See CHANGES.md for the full history and FLOW.md for how the commands work inside.
Yoda is licensed under the Apache License 2.0.
