How to DooD (Docker outside of Docker) in GoCD agent clearly?

58 views
Skip to first unread message

MerNat

unread,
Jan 29, 2020, 7:24:44 AM1/29/20
to go-cd
I found out when using DooD in GoCD we just only need to add 
/var/run/docker.sock:/var/run/docker.sock
as a volume to the current agent container as clearly defined and written in the official documentation: https://docs.gocd.org/current/gocd_on_kubernetes/docker_workflows.html.

What I couldn't understand is, even though I've added that volume I couldn't run docker commands using the command: "/bin/bash", arguments: -c \n docker image within the task of goCD server.

Now, I'm wondering if there is clear documentation or steps to make the GoCD agent able to pass a docker commands to the host machine.

Michael Mann

unread,
Jan 29, 2020, 7:31:46 AM1/29/20
to go-cd
You will need to use pipelines as code until the bug is fixed in the next release. You can see the problem if you export your pipelines and look at the yaml file. There is an extra carriage return inserted that is causing the failure

MerNat

unread,
Jan 29, 2020, 8:13:37 AM1/29/20
to go-cd
Ok, well I think I might use pipelines as code. But i also tried to execute a docker command from the agent container itself (i.e. docker exec -it -u go <machine> bash). Sadly it has returned with:

bash-5.0$ /bin/bash -c "docker images"
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/json: dial unix /var/run/docker.sock: connect: permission denied

I think it has to be an issue with the user "go" regarding to have access to the docker socket.

Any suggestion?

Michael Mann

unread,
Jan 29, 2020, 9:05:45 AM1/29/20
to go-cd
Yes, check the permissions on the docker.sock file on the host. I’m guessing it’s owned by root the user in the agent container does not have rights. Change ownership of the docker.sock to the logged in user on the Linux host and leave the group ownership the same

Felipe Illanes

unread,
Jan 29, 2020, 9:30:50 AM1/29/20
to go...@googlegroups.com
GoCD use go as default user. Is important that the host dont get another user go, like for example a user for golang. I got that problem, so I share my experience.

Another tip, was share godata folder, for plugins and xml configs. Any time you make changes you must restart the container, and is a must share godata folder. So i share godata and docker.sock

On Wed, Jan 29, 2020 at 11:05 AM Michael Mann <mman...@gmail.com> wrote:
Yes, check the permissions on the docker.sock file on the host.  I’m guessing it’s owned by root the user in the agent container does not have rights.  Change ownership of the docker.sock to the logged in user on the Linux host and leave the group ownership the same

--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/60c39882-b590-4505-a3f6-c294f6703f95%40googlegroups.com.


--

MerNat

unread,
Jan 29, 2020, 10:24:27 AM1/29/20
to go-cd
I has worked Michael, thanks to you! :) Though does the issue that you told me pointed out in Github?

Michael Mann

unread,
Jan 29, 2020, 11:00:33 AM1/29/20
to go-cd
Yes, here is the link https://github.com/gocd/gocd/issues/7557. Glad I could help.
Reply all
Reply to author
Forward
0 new messages