git-hash Embed git hash in golang Build & Run docker build \ --build-arg GIT_VERSION=$(git rev-parse --short HEAD) \ -t xshyamx/git-hash . \ && docker run --rm xshyamx/git-hash References Inject build-time variables with Golang Create the smallest and secured golang docker image based on scratch