Setting up GoCD in Docker Swarm Mode

Posted in category gocd on 2017-04-10

Establish overlay network

Start GoCD Server

Choose one node that will run gocd-server and create following folders:

Label this node as following (choose one inspecting the output of docker node ls):

Here is how to create go-server service:

You may want to choose kuznero/gocd-server-65011:latest auto built version that is using ${GID}=65011 and ${UID}=65011 instead of 1000 if it happen to collide with users/groups on your docker host.

Start GoCD Agents

It will be assumed that go-agent service should use docker facilities where it is hosted itself. For that it is required to share (i.e. mount) docker client and its libraries into go-agent containers docker client can be used as if go-agent has docker infrastructure installed in it natively.

And this is how to create go-agent service:

Mounting docker with some of its dependent libraries might not work specifically in case of your OS/Docker version combination.

There are different versions of gocd-agent-* available, but ubuntu flavor was chosen specifically because mounted docker client is most likely to be compatible with it.

Do not forget that in order for the trick of re-using outer docker client to work there should be a few thinkgs in place:

  1. Docker engine where go-agent is going to be running should be started with the following option: -H unix:///var/run/docker.sock
  2. /var/run/docker.sock file should have appropriate permissions, thus please ensure: chmod 0666 /var/run/docker.sock