From d4c270a18df3792c581f3ab099f4bbbba46fd988 Mon Sep 17 00:00:00 2001 From: Lucy Davies Date: Sat, 9 Jun 2018 15:18:22 +0100 Subject: [PATCH] Helper function: bind docker socket --- task.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/task.go b/task.go index 97cc2ca..d9af702 100644 --- a/task.go +++ b/task.go @@ -89,3 +89,19 @@ func (t *Task) Bind(src, dst string) (string, error) { } return fmt.Sprintf("%s:%s", expanded, dst), nil } + +// BindDockerSocket is a utility function which binds the docker socket +func (t *Task) BindDockerSocket() error { + // For now, assumes /var/run/docker.sock from host + // Untested with remote docker + dockerSocket, err := t.Bind("/var/run/docker.sock", "/var/run/docker.sock") + if err != nil { + return err + } + + t.AddBinds([]string{dockerSocket}) + + return nil +} + +// TODO: add tests