Skip to content

Building functions

Building a function creates an OCI container image for your function that can be pushed to a container registry. It does not run or deploy the function, which can be useful if you want to build a container image for your function locally, but do not want to automatically run the function or deploy it to a cluster, for example, in a testing scenario.

Local builds

You can build a container image for your function locally without deploying it to a cluster, by using the build command.


  • You have a Docker daemon on your local machine. This is already provided if you have used the Quickstart installation.


The build command uses the project name and the image registry name to construct a fully qualified container image name for the function. If the function project has not previously been built, you are prompted to provide an image registry.

To build the function, run the following command:

func build

To build the function, run the following command:

kn func build


The coordinates for the image registry can be configured through an environment variable (FUNC_REGISTRY) as well.

On-cluster Builds

If you do not have a local Docker daemon running, or you are using a CI/CD pipeline, you might want to build your function on the cluster instead of using a local build. You can create an on-cluster build by using the func deploy --remote command.


If you're doing a direct-upload deployment (i.e. the source code is on your local machine instead of a git repo), you can create an on-cluster build without the need of specifying the Git URL, but if you already specified a Git URL before, you'll need to specify the flag as empty, using the command func deploy --remote --git-url=""


  • The function must exist in a Git repository.
  • You must configure your cluster to use Tekton Pipelines. See the on-cluster build documentation.


When running the command for the first time, you must specify the Git URL for the function:

func deploy --remote --registry <registry> --git-url <git-url> -p hello
kn func deploy --remote --registry <registry> --git-url <git-url> -p hello

After you have specified the Git URL for your function once, you can omit it in subsequent commands.

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.

× OK