Build Modes¶
PeiDocker supports three distinct workflows. The default docs path uses the two-stage Compose workflow, but you do not have to use both stages.
Quick Decision¶
| Mode | Config shape | configure writes |
Build / run path | Good fit |
|---|---|---|---|---|
stage-1-only |
Only stage_1 in user_config.yml |
docker-compose.yml with only the stage-1 service |
docker compose build stage-1 and docker compose up -d stage-1 |
Small SSH-ready or system-base containers |
two-stage Compose |
stage_1 plus stage_2 |
docker-compose.yml with both services |
docker compose build ... and docker compose up ... |
Default development workflow with storage and final runtime behavior |
merged build |
stage_1 plus stage_2 |
docker-compose.yml plus merged.Dockerfile, merged.env, build-merged.sh, and run-merged.sh |
./build-merged.sh and ./run-merged.sh |
Plain docker build / docker run workflow while keeping the two-stage model |
merged build is not the same as stage-1-only.
stage-1-onlychanges the config shape by omittingstage_2.merged buildkeeps both stages in the config and changes only how you build and run them.
1. stage-1-only¶
Use this when you want the simplest practical container and do not need stage-2 storage or stage-2 runtime customization yet.
Minimal config:
stage_1:
image:
base: ubuntu:24.04
output: pei-example-stage1-only:stage-1
ssh:
enable: true
port: 22
host_port: 2222
users:
dev:
password: "123456"
Workflow:
pei-docker-cli create -p demo --quick minimal
# Replace demo/user_config.yml with the stage-1-only config above
cd demo
pei-docker-cli configure
docker compose build stage-1
docker compose up -d stage-1
ssh dev@localhost -p 2222
What changes:
- The generated
docker-compose.ymlcontains only thestage-1service. - The project scaffold still includes stage-2 template files, so you can add
stage_2later without recreating the project.
2. two-stage Compose (Default)¶
Use this when you want the full PeiDocker model: a reusable system base in stage-1 and a final runtime image in stage-2.
This is the best default when you need:
stage_2.storage- extra runtime ports
- runtime-oriented hooks
- a final image that keeps app-layer customization separate from the system base
Workflow:
pei-docker-cli create -p demo --quick minimal
cd demo
pei-docker-cli configure
docker compose build stage-1
docker compose build stage-2
docker compose up -d
ssh me@localhost -p 2222
Start here if you are unsure. Then read Quickstart and Two-Stage Architecture.
3. merged build¶
Use this when you want to keep the logical two-stage model but build and run the final image through generated helper scripts instead of the default Compose build path.
Workflow:
pei-docker-cli create -p demo --quick minimal
cd demo
pei-docker-cli configure --with-merged
./build-merged.sh
./run-merged.sh -d
ssh me@localhost -p 2222
Generated artifacts:
merged.Dockerfilemerged.envbuild-merged.shrun-merged.sh
Important constraints:
merged buildstill usesstage_1andstage_2from your config. It is not astage-1-onlyshortcut.- Compose passthrough markers such as
{{VAR}}are incompatible with--with-merged.
Which One Should A First-Time User Pick?¶
- Pick
stage-1-onlyif your immediate goal is “give me one SSH-ready container and I do not need stage-2 features yet”. - Pick
two-stage Composeif you want the default PeiDocker workflow and expect to use storage, runtime hooks, or a final stage-2 image. - Pick
merged buildif your real requirement is “keep the two-stage model, but build with one generateddocker buildworkflow”.
Next Step¶
- Follow Quickstart for the default two-stage path.
- Use 01 Minimal SSH if you want the smallest default example explained line by line.
- Read CLI Reference for command details and Two-Stage Architecture for the deeper model behind the default workflow.