Getting started with Go Microservices and Docker

What is a microservice

First, you need to learn about the go language. Do these pages in order to learn the bare basics:

Then you’ll need to learn what docker is, read the understanding docker page:

And then go install docker and run their hello-world example:

Now hopefully you have the basics of go and docker down, so let’s grab an existing microservice and set it up.

On your docker host run:

tar -zxf master.tar.gz
cd go-docker-playground-master
docker build --tag=danzel/go-docker-playground:1.0 .

This will fetch and then build this docker image which contains a simple web server. Now we can start it up with:

docker create --name=test -P danzel/go-docker-playground:1.0
docker start test

Docker will automatically expose the server on a free port (Thanks to EXPOSE in the Dockerfile and -P in the docker create command line).
To see the port it has chosen:

docker ps

Then you should be able to open it by browsing to http://dockerhostip:port