Recently while I was trying to install a Docker related app called docker-squash on OSX El Capitan.
For those who are not familiar with the utility; docker squash is a nice utility that reduces the size of docker images by removing the layers
However when running the command
go get github.com/docker/docker/pkg/units
I was getting the following error message :
Building docker-squash export.go:19:2: cannot find package "github.com/docker/docker/pkg/units" in any of: /usr/lib/go/src/pkg/github.com/docker/docker/pkg/units (from $GOROOT) /root/t/docker-squash/src/github.com/docker/docker/p
Below I will show you how to build docker squash step by step (some steps can be omitted i.e. installing go if you already have installed)
Install go and set-up variables
brew install go mkdir $HOME/.go export GOPATH=$HOME/.go export PATH=$PATH:$GOPATH/bin
Clone the docker squash repo
I'm not sure this is required but clone the repo under ~/.go/src/github.com/jwilder/docker-squash/
git clone https://github.com/jwilder/docker-squash.git
Install glock and sync your repo
under the folder ~/.go/src/github.com/jwilder/docker-squash/ run the following command
go get github.com/robfig/glock
Once the command finished sync your local repo with glock
glock sync github.com/jwilder/docker-squash
Install the units package
go get github.com/docker/docker/pkg/units
Build docker squash
GOBIN=$(pwd) make
Install gnu-tar and added to the path
brew install gnu-tar PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"
Move the executable to a bin folder
You should now have a docker-squash executable in your local repository; move the executable to a bin folder of your choice for example /usr/local/bin/
You should now be able to run docker-squash from your mac
Final thoughts and remarks
If you use docker-squash frequently you should change your .bashrc to do this automatically