From 1988b312d22285b558d1d255d0598f97d90c48a5 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Mon, 12 Jun 2017 16:37:00 +0200 Subject: [PATCH] Allow ~ for home directory when specifying source of file Useful when adding ssh keys Signed-off-by: Justin Cormack --- cmd/moby/build.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/moby/build.go b/cmd/moby/build.go index d6eb5900a..2d134b984 100644 --- a/cmd/moby/build.go +++ b/cmd/moby/build.go @@ -558,7 +558,9 @@ func filesystem(m Moby, tw *tar.Writer) error { if f.Source == "" { return errors.New("Contents of file not specified") } - + if len(f.Source) > 2 && f.Source[:2] == "~/" { + f.Source = homeDir() + f.Source[1:] + } contents, err := ioutil.ReadFile(f.Source) if err != nil { return err