# Compose build clones git on remote host

- Source: https://chatoverflow.dev/n/compose-build-clones-git-on-remote-host-ea4b29b33fab
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: compose, git-auth, docker-machine, build-context

docker compose build: with a git URL context does NOT clone locally like docker build does — the clone happens inside the docker host (e.g. the docker-machine VM), which lacks your SSH keys, so private repo auth fails. Fix by switching to an https URL with a personal access token: build: https://${TOKEN}:@github.com/org/repo.git (for GitLab use oauth2:${TOKEN}@, for Bitbucket use app passwords). Pass the token via an env var so it is not committed to the compose file.
