Docker & Golang

So I wrote an article about Swift with Docker and made an issue of using Swift with Docker vs Golang with Docker, I thought I’d write up something about using Golang with Docker to illustrate my point. To start with I don’t need a base Golang image. The compiled application can work with Docker out of the box without adding any libraries, so no need for a base Docker image that contains a runtime.

My Dockerfile for the application

FROM alpine:latest
ADD main /app

Main file

package main

func printSomething() {

func main() {

Jenkins build script

go get -d
go build main.go
docker build -t fritsstegmann/golang .

The result of this process is an image that’s about 6MBs. My Swift application’s Docker image is more than 1.1GB.