Build Docker image from scratch

Hello! I am trying to build a docker image from scratch from the provided Dockerfile in the repo but an error is thrown upon building:

=> ERROR [builder 5/5] RUN go install -a -trimpath -ldflags “-s -w -X$(date -u +”%FT%T%z")/$(git describe --tags --always --long --dirty)" 0.3s

[builder 5/5] RUN go install -a -trimpath -ldflags “-s -w -X$(date -u +”%FT%T%z")/$(git describe --tags --always --long --dirty)":
#12 0.287 fatal: not a git repository (or any of the parent directories): .git
#12 0.290 go: go.mod file not found in current directory or any parent directory; see ‘go help modules’

executor failed running [/bin/sh -c go install -a -trimpath -ldflags “-s -w -X$(date -u +”%FT%T%z")/$(git describe --tags --always --long --dirty)"]: exit code: 1

Hi @stanislav3885

Do you mean trying to build k6 from this Dockerfile fails for you? If so, do you clone the k6 repo locally and then run the build, or just use the Dockerfile?

Can you share the steps you follow and the Dockerfile if you have modified anything in the Dockerfile?


Yes, I used the only the Dockerfile you mentioned, without cloning the k6 repo.

Steps which I follow was:

  1. Copy the Docker file
  2. Simple build docker command.

Hi @stanislav3885

This is more in the realm of Docker than k6, so you should probably seek help in the Docker documentation and forums. The Dockerfile from our repo builds from the git repository, so you will need to clone it to make it work. There is usually no need to build from source, unless you are developing k6. However, if you require that, you should be able to do it cloning the repository.