Context
Source:
src/Docker/Context.ts
A named Docker CLI context — a pointer to a Docker engine (local socket, SSH host, or TCP endpoint) that other Docker resources deploy through.
Pass the context (or its name) to any Docker resource’s context prop to
run that resource’s operations against the referenced engine instead of the
default one. Changing the endpoint updates the context in place; renaming
it, or clearing a previously-set endpoint, replaces it.
Creating Contexts
Section titled “Creating Contexts”const vps = yield* Docker.Context("vps", { docker: "host=ssh://deploy@example.com", description: "production swarm manager",});Using a Context
Section titled “Using a Context”Deploy resources through the context
const vps = yield* Docker.Context("vps", { docker: "host=ssh://deploy@example.com",});const network = yield* Docker.Network("app-net", { context: vps, driver: "overlay",});const app = yield* Docker.Service("app", { context: vps, image: "nginx:alpine", networks: [network.name],});Local development vs production
const dev = yield* Alchemy.ALCHEMY_DEV;const context = yield* Docker.Context("target", { name: dev ? "local" : "vps", docker: dev ? undefined : "host=ssh://deploy@example.com",});