Skip to content
Building and Deploying Minimize Golang Executable Docker Image with Alpine Linux
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.


Travis CI


A template for deploying a minimize golang binary docker image, which size only about 10 MB.

This example uses Travis CI and Heroku to make a demo.

Docker version higher than 17.05

Use multi-stage builds, the example Dockerfile

Docker version lower than 17.05

Make two docker file

  • DockerSrc for building binary
  • DockerBin for execution

See the example in old folder


Image Size
source code image 282 MB
binary image 10.5 MB


Function time.LoadLocation() will panic in binary image, because of

LoadLocation looks in the directory or uncompressed zip file named by the ZONEINFO environment variable, if any, then looks in known installation locations on Unix systems, and finally looks in $GOROOT/lib/time/

You have to set $GOROOT and copy manually.


You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.