# docker init: Scaffold Dockerfiles & Compose

> How docker init works: scaffolding a Dockerfile, .dockerignore, and compose.yaml for a project, language detection, and CI prep.

Source: https://latchkey.dev/learn/command-reference/docker-init-command  
Updated: 2026-06-25

Scaffold a Dockerfile, .dockerignore, and compose.yaml for a project.

docker init detects your project type and generates starter Docker assets. This page covers what it creates and how to use it as a CI starting point.

## What it does

docker init runs an interactive wizard that detects the language/framework and writes a Dockerfile, .dockerignore, compose.yaml, and a README.Docker.md tuned to it. It is a scaffolding aid, not a build step.

## Common usage

```Terminal
docker init
# follow the prompts to pick platform/language
docker build -t myapp .
docker compose up
```

## Common errors in CI

docker init is interactive and prompts for input, so it does not belong in a non-interactive CI job - run it locally once and commit the generated files. If the files already exist it asks before overwriting; a no-TTY environment cannot answer that prompt. Treat its output as a starting point to harden (pin base image versions, slim layers) before relying on it in CI.

## FAQ

### docker init: Scaffold Dockerfiles & Compose?

docker init detects your project type and generates starter Docker assets. This page covers what it creates and how to use it as a CI starting point.

### What it does?

docker init runs an interactive wizard that detects the language/framework and writes a Dockerfile, .dockerignore, compose.yaml, and a README.Docker.md tuned to it. It is a scaffolding aid, not a build step.

### Common errors in CI?

docker init is interactive and prompts for input, so it does not belong in a non-interactive CI job - run it locally once and commit the generated files. If the files already exist it asks before overwriting; a no-TTY environment cannot answer that prompt.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
