Skip to main content


Daggerize a project

So far, you've learned the basics of calling Dagger Functions. The next step is to use them in the context of your software project.

Here are the basic steps to Daggerizing an existing project:

  1. Initialize a new Dagger Module with dagger init
  2. Install other useful Dagger Modules as dependencies with dagger install
  3. Call useful Dagger Functions with dagger call
  4. Add useful dagger call commands to existing scripts and CI configuration

Try these steps by Daggerizing an example project - a simple "Hello world" application from the official Go example repository.

Fetch the project repository

Fetch a copy of the project repository:

git clone
cd example

Initialize a Dagger module

Initialize a Dagger module at the root of the repository:

dagger init

You should see a new file at the root of your repository, named dagger.json. View its contents:

cat dagger.json

You should see the following:

"name": "example",
"engineVersion": "v0.10.1"

By default, the module name is derived from the name of the directory in which it is initialized. To use a different name, add the --name argument to the dagger init call - for example, dagger init --name=my-module.

Finally, commit the file to your repository:

git add dagger.json
git commit -m 'dagger init'

Congratulations! Your repository is now a Dagger Module.

Install a dependency

Now that your project is a Dagger Module, you can install other modules into it, as dependencies. A dependency is just a Dagger Module installed into another. As an example, install the hello module from earlier:

dagger install

Once the command completes, look at the dagger.json file again. You should see that a new dependency has been added, similar to that shown below:

"name": "example",
"sdk": "go",
"dependencies": [
"name": "hello",
"source": ""
"source": "dagger",
"engineVersion": "v0.10.1"

The exact Git commit for the module version is recorded in dagger.json. Dagger enforces "version pinning", which guarantees that the module version you install is the one you'll be using.

Go ahead and commit this change as well:

git add dagger.json
git commit -m 'dagger install'

Use the installed module

Now that your module has its first dependency installed, you can start using it! To do so, simply refer to it by its short name - in this case, hello.

List available functions:

dagger -m hello functions

You should see a familiar result:

Name    Description
hello Say hello to the world!

Call a function:

dagger -m hello call hello

Again, the output should be familiar:

hello, world!

Daggerize a Go build

The hello module is a good example to start with, but it doesn't have any functions to work with a Go project. To Daggerize the Go build for this example project, install the Go builder module from a previous section as another dependency:

dagger install

Then, call the BuildContainer() function from the Go builder module to build the project and publish a container image with the built binary:

dagger -m golang call \
build-container --source=. --args="-C","./hello" \

Once the container image is built, you should see the address at which it was published, as in the example below:

Test the published container image using the command below (remember to update the image name based on the function output):

docker run \
--name ctr \
--rm \
-it /usr/local/bin/hello

You should see the following output:

Hello, world!

Your project is slowly becoming more and more're now able to build it, containerize it and publish it, all with a single Dagger Function call. If you like, you can integrate this call into your existing shell scripts, or perhaps a Makefile. Or, you can create a custom Dagger Module, which enables you to connect one or more Dagger Functions together in portable, expressive workflows with all the benefits of a native programming language.