Skip to content
A toolkit to create installers based on docker compose.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

go-compose-installer GoDoc

A toolkit to create installers based on docker compose.

go-compose-installer allows to deploy complex infrastructure applications using a single binary, with no more dependencies than docker.


This is an example based on the docker compose tutorial, this example installs a basic environment based on a web server backed by a redis service.

package main

import (

func main() {
	// New default Config, containing a suite of standard messages to be
	// printed at every operation.
	cfg := installer.NewDefaultConfig()

	// Name of the project, to be used in the messages.
	cfg.ProjectName = "example"

	// Compose YAML content, a standard docker compose version 2 file.
	cfg.Compose = [][]byte{yml}

	// The defined YAML, contains a template, some variables are not standard
	// variables, so we need to define it at the `Config.TemplateVars` field.
	cfg.TemplateVars = map[string]interface{}{
		"RedisTag": "4.0.6-alpine",

	// Customized message for a success installation.
	cfg.Install.Messages.Success = "" +
		"The example was successfully installed!\n\n" +

		"To test the deployment please navigate to:\n" +
		"http://localhost:5000\n\n" +

		"To uninstall this example, just execute:\n" +
		"./example uninstall\n"

	// New instance of a Installer based on the given Config.
	p, err := installer.New("compose-installer-example", cfg)
	if err != nil {

	// Execution of the application.

// Standard docker compose yaml file from:
var yml []byte = []byte(`
version: '2'
    image: srcd/compose-example
     - "5000:5000"
    image: "redis:{{.RedisTag}}"

The following code provides an CLI application allowing to anyone with just one command to install, start, stop and uninstall the environment, without any external dependency besides docker.

  compose-installer-example [OPTIONS] <command>

Help Options:
  -h, --help  Show this help message

Available commands:
  install    Installs example into your system.
  start      Stars example.
  status     Show the status of example.
  stop       Stops example.
  uninstall  Remove example from your system.

Go Template support

Go templates are supported in the yaml file and also at all the messages.

The Template variables can be configured at the Config.TemplateVars, additionally to the custom defined variables some other variables are defined by default.

This is the list of default variables:

  • .Project - The project name, from the given Config.ProjectName.
  • .Home - Home folder of the user executing the installer.
  • .OS - Content of runtime.GOOS.
  • .Arch - Content ofruntime.GOARCH.
  • .Error - Only available at Failure messages, is the string of the error.


Apache License Version 2.0, see LICENSE

You can’t perform that action at this time.