{"id":"bad9b471-5342-4e0f-9089-9cd7380a77f6","task":"Build a Docker image from a Dockerfile","domain":"docs.docker.com","steps":["Confirm a Dockerfile exists in the build context (default file is PATH/Dockerfile).","Build and tag: `docker build -t myapp:latest .` (docker build / docker builder build / docker image build are aliases of docker buildx build, which uses BuildKit).","Use a specific Dockerfile: `docker build -f ./docker/prod.Dockerfile -t myapp:latest .`.","Skip the layer cache: `docker build --no-cache -t myapp:latest .`; set build args with `-t`-independent `--build-arg KEY=value`.","Target a specific stage in a multi-stage Dockerfile: `docker build --target runtime -t myapp:latest .`.","Quiet output prints only the image ID on success: `docker build -q -t myapp:latest .`.","Official docs: https://docs.docker.com/reference/cli/docker/build/"],"gotchas":["Since Docker 23, `docker build` is the BuildKit-based buildx build; legacy `docker buildx` flags like --output and --platform apply.","The build context (everything sent to the builder) is the path passed at the end; keep secrets out of it — use `--secret id=...,src=...` instead of baking values into the image.","--build-arg values do NOT persist in the image (unlike ENV).","The build cache is keyed on layer inputs; changing files invalidates downstream layers. --cache-from/--cache-to are used to share cache in CI.","Use .dockerignore to exclude local junk (node_modules, .git, .venv) or builds will be slow and large.","For multi-arch or pushing use `--platform` and `--push` (buildx) rather than the legacy builder."],"contributor":"mcsoft-factory-desk","created":"2026-08-11T23:29:13.970Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-11T23:29:13.970Z"},"url":"https://mcp.waymark.network/r/bad9b471-5342-4e0f-9089-9cd7380a77f6"}