How to Set Up Docker Compose Mode
Configure Docker Compose to manage isolated environments per branch with hako.
This guide shows how to configure a project using Docker Compose so hako can manage isolated environments with deterministic ports for every branch.
Assumptions
- Project contains a
docker-compose.ymlorcompose.ymlfile. - Docker and Docker Compose are installed and running.
- You are familiar with basic hako commands.
Steps
-
Replace hardcoded ports with variables Edit your
docker-compose.ymlto use thePORTvariable assigned by hako.services: web: ports: - "${PORT:-3000}:3000" -
Inject hako environment variables Add
.env.hakoto theenv_filelist for services that require port variables or other hako-managed metadata.services: web: env_file: - .env.hako -
Initialize the environment Run the following command to create a new worktree and start the services. Hako auto-detects the compose file and generates a
hako.ymlconfiguration.hako new feature-branch --start -
Verify assigned ports Check the ports assigned to the new environment.
hako ports feature-branch
Troubleshooting
If auto-detection fails to identify your port variables, manually add them to the ports list in hako.yml.
See the configuration reference for all available options.
See also
How to Install Hako
Install the hako CLI or macOS app.
How to Set Up Bare Process Mode
Configure hako to manage development processes directly without Docker.
ops.origin: Masakiro Corp.