Skip to content
All writing Part 04 of 09 · Reaching a Remote DB From Your Laptop
Engineering · 2 min read

docker-compose image vs build: Provenance, Not Existence

In docker-compose, both image: and build: end up running an image; the fork is where it comes from. And build.context is mandatory, because COPY resolves relative to it.

Both image: and build: end up running an image; Docker never runs raw source. The fork is where the image comes from:

image: pulled ready-made from a registry build: compiled locally from Dockerfile + files run an image both end up running an image; the fork is only where it comes from
image: pulls ready-made, build: compiles locally. Both run an image; the difference is provenance.
DirectiveImage sourceLocal build step?
image:pulled ready-made from a registry
build.context:compiled locally from Dockerfile + files✅ (first run / --build)

build.context is mandatory for a build: you cannot “just point at a Dockerfile.” The context is the file tree handed to the daemon; COPY x resolves relative to the context, so no context means nothing to copy from. (dockerfile: only names the recipe; context: is still required.) Use both together to name a locally-built image.

From this session: the ClickHouse services use build: {context: ./clickhouse-portforward} because no prebuilt image bundles gcloud + kubectl + auth-plugin + entrypoint; the Cloud SQL services use image: (the public gce-proxy), so no build.

image: pulls ready-made, build: compiles locally. Both end up running an image; the difference is only provenance.


References

Related: back to the remote DB overview; then COPY bakes in, volumes mount live.

Tags #docker #devops
// connect

Be brave | Be wise | Be grateful

21 BreakinCode

// elsewhere
LinkedInMedium (lang: en)Life RecordYoutube
wh:~$William Hung· © 2026 Taipei · GMT+8 · Available for collaboration