docker/compose · error
output folder %s already exists
Error message
output folder %s already exists
What it means
bridge.CreateTransformer scaffolds a new transformer by materializing a folder from a container image (default DefaultTransformerImage). As a safety guard it refuses to run if the destination path already exists (os.Stat succeeds), so it never overwrites or merges into an existing folder. The message prints the absolute destination path.
Source
Thrown at pkg/bridge/transformers.go:53
templatesPath = "/templates"
)
type CreateTransformerOptions struct {
Dest string
From string
}
func CreateTransformer(ctx context.Context, dockerCli command.Cli, options CreateTransformerOptions) error {
if options.From == "" {
options.From = DefaultTransformerImage
}
out, err := filepath.Abs(options.Dest)
if err != nil {
return err
}
if _, err := os.Stat(out); err == nil {
return fmt.Errorf("output folder %s already exists", out)
}
tmpl := filepath.Join(out, "templates")
err = os.MkdirAll(tmpl, 0o744)
if err != nil && !os.IsExist(err) {
return fmt.Errorf("cannot create output folder: %w", err)
}
if err := command.ValidateOutputPath(out); err != nil {
return err
}
created, err := dockerCli.Client().ContainerCreate(ctx, client.ContainerCreateOptions{
Image: options.From,
})
defer func() {
_, _ = dockerCli.Client().ContainerRemove(context.Background(), created.ID, client.ContainerRemoveOptions{View on GitHub (pinned to ddc4b044b6)
Solutions
- Choose a fresh destination path that does not exist yet
- Remove or rename the existing folder if its contents are disposable: rm -rf <dest>
- Move the existing folder aside (mv dest dest.bak) if you need to compare or preserve it
Example fix
# before $ create-transformer --dest ./my-transformer output folder /path/to/my-transformer already exists # after $ mv ./my-transformer ./my-transformer.bak $ create-transformer --dest ./my-transformer
Defensive patterns
Strategy: validation
Validate before calling
// Before CreateTransformer:
if _, err := os.Stat(options.Dest); err == nil {
return fmt.Errorf("destination %s already exists, pick a new path or remove it", options.Dest)
} Prevention
- Generate a fresh destination per run (timestamp or uuid suffix) in automation
- Clean or version transformer output dirs in CI between runs
- Treat CreateTransformer as scaffolding: run once, commit the result
When it happens
Trigger: Calling CreateTransformer with options.Dest set to an existing directory or file; running the scaffolding command twice with the same destination; a previous partial run that left the folder behind.
Common situations: Re-running a transformer-creation command after an interrupted first attempt; pointing Dest at a checked-in project directory that already exists; CI caching that preserves the destination between runs.
Related errors
- cannot create output folder: %w
- cannot create output folder: %w
- failed to export container: %w
- source can not be empty
- destination can not be empty
AI-assisted analysis of docker/compose@ddc4b044b6 (2026-08-15).
Data as JSON: /api/errors/db8882aeba9b8162.
Report an issue: GitHub.