Skip to content
LatchkeyLatchkey home

docker init: Scaffold Dockerfiles & Compose

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.

Frequently asked questions

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.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card