Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

MOVED: I've created a new follow on project for Go and other languages here:

This is a Docker image to help you develop in Go (golang). The great thing is you don't need to have anything installed except Docker, you don't even need Go installed. See this post about developing with Docker.

This image can perform the following functions:

  • vendor - vendors your dependencies into a /vendor directory.
  • build - builds your program using the vendored dependencies, with no import rewriting.
  • remote - this one will produce a binary from a GitHub repo. Equivalent to cloning, vendoring and building.
  • image - this will build and create a Docker image out of your program.
  • cross - cross compile your program into a variety of platforms. Based on this.
  • static - statically compile your program. This is great for making the tiniest Docker image possible.


Vendor dependencies:

docker run --rm -it -v "$PWD":/app -w /app treeder/go vendor

You may need to add more options if you have subdirectory imports:

docker run --rm -it -v "$PWD":/app -w /app -e "" treeder/go vendor

The SRCPATH should match your local import statements. Only required if you have subdirectories in the current repository that you are using in imports.


docker run --rm -v "$PWD":/app -w /app treeder/go build


This is just a normal Docker run. I'm using iron/base here because it's a tiny image that has everything you need to run your Go binary on.

docker run --rm -v "$PWD":/app -w /app -p 8080:8080 iron/base ./app


docker run --rm -v "$PWD":/app -w /app treeder/go fmt

Advanced Commands

Build a remote git repo:

This produces a binary given a remote git repo containing a Go program.

docker run --rm -v "$PWD":/app -w /app treeder/go remote

You'll end up with a binary called app which you can run with the same command as above.

Build a Docker image out of your program:

This will build a Docker image with your program inside it.

The argument after image is IMAGE_NAME:tag. Also, note the extra mount here, that's required to talk to the Docker host.

docker run --rm -v "$PWD":/app -w /app -v /var/run/docker.sock:/var/run/docker.sock treeder/go image username/myapp:latest

Boom, creates a small Docker image for you. Run docker images to check it out, should be about ~12MB total.

Test your new image:

docker run --rm -v "$PWD":/app -w /app -p 8080:8080 username/myapp

Cross compile:

This uses a different image, treeder/go-cross, to do a cross compile.

docker run --rm -v "$PWD":/app -w /app treeder/go-cross cross

Build static binary:

This is great for making the tiniest Docker image possible

docker run --rm -v "$PWD":/app -w /app treeder/go static

Check Go version:

docker run --rm treeder/go version

Wrapper Script

We've provided a script to make running each command more convenient.

To use it, download it and put it in your $PATH. Then, create an alias for it by pasting the following into your shell config file (e.g. .bashrc, .zshrc, etc...):

alias dgo=''

Now you're ready to run the wrapper. It supports the following commands:

  • dgo build
  • dgo cross
  • dgo static
  • dgo vendor
  • dgo image
  • dgo run
  • dgo run-static



Building this image

docker build -t treeder/go:latest .

Tag it with Go version too (can check with docker run --rm treeder/go version):

docker tag treeder/go:latest treeder/go:1.4.2


docker push treeder/go


Go tool that uses Docker and only Docker.






No releases published


No packages published

Contributors 4