| 1 | --- |
| 2 | title: Setup |
| 3 | description: Point alchemy at a Docker daemon — the active CLI context and the DOCKER_BIN override. |
| 4 | --- |
| 5 | |
| 6 | Register the provider in your stack: |
| 7 | |
| 8 | ```typescript |
| 9 | // alchemy.run.ts |
| 10 | import * as Docker from "alchemy/Docker"; |
| 11 | |
| 12 | providers: Docker.providers(), |
| 13 | state: Alchemy.localState(), |
| 14 | ``` |
| 15 | |
| 16 | That's the whole registration. When Docker runs alongside a cloud |
| 17 | provider, merge the layers: |
| 18 | `providers: Layer.merge(Cloudflare.providers(), Docker.providers())`. |
| 19 | |
| 20 | ## Prerequisites |
| 21 | |
| 22 | A Docker daemon reachable from the `docker` CLI is the only |
| 23 | requirement. The provider shells out through the **active Docker CLI |
| 24 | context**, so whatever `docker ps` talks to — Docker Desktop, a |
| 25 | remote Docker host, an SSH context, a CI runner's daemon — is what |
| 26 | alchemy provisions against. There is no login step and no |
| 27 | stored token: this provider has no credentials of its own. |
| 28 | |
| 29 | ## Binary override |
| 30 | |
| 31 | ```sh |
| 32 | DOCKER_BIN=/opt/homebrew/bin/docker bun alchemy deploy |
| 33 | ``` |
| 34 | |
| 35 | The provider resolves the Docker binary from the `DOCKER_BIN` |
| 36 | environment variable, falling back to `docker` on the `PATH`. |
| 37 | |
| 38 | ## Registry credentials |
| 39 | |
| 40 | Registry auth is a per-resource prop, not global configuration. |
| 41 | [`Image`](/providers/docker/image) and |
| 42 | [`RemoteImage`](/providers/docker/remoteimage) accept a `registry` |
| 43 | with `{ server, username, password }`, where `password` is a |
| 44 | `Redacted` value: |
| 45 | |
| 46 | ```typescript |
| 47 | const image = yield* Docker.Image("app", { |
| 48 | name: "my-app", |
| 49 | build: { context: "./app" }, |
| 50 | registry: { |
| 51 | server: "ghcr.io", |
| 52 | username: "octocat", |
| 53 | password: Config.Redacted("GITHUB_TOKEN"), |
| 54 | }, |
| 55 | }); |
| 56 | ``` |
| 57 | |
| 58 | Push deliberately skips `docker login`: the credentials are written |
| 59 | into an isolated `DOCKER_CONFIG` that only the push command reads, so |
| 60 | your global docker config, buildx builders, and `docker context` |
| 61 | setup stay intact. |
| 62 | |
| 63 | ## Next steps |
| 64 | |
| 65 | - [Docker overview](/docker) — resources and compositions. |
| 66 | - [Run local services](/docker/local-services) — Postgres with a |
| 67 | network, volume, and healthcheck. |
| 68 | - [Build and push an image](/docker/build-and-push) — Dockerfile |
| 69 | builds and registry push. |