From 5ee3c58d2549c25fa4464963831a28a99407b6cd Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 13 Aug 2013 12:02:17 +0000 Subject: [PATCH] Add USER instruction --- buildfile.go | 5 +++++ buildfile_test.go | 11 +++++++++++ docs/sources/use/builder.rst | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/buildfile.go b/buildfile.go index 5a2662646e..06ca331a40 100644 --- a/buildfile.go +++ b/buildfile.go @@ -197,6 +197,11 @@ func (b *buildFile) CmdExpose(args string) error { return b.commit("", b.config.Cmd, fmt.Sprintf("EXPOSE %v", ports)) } +func (b *buildFile) CmdUser(args string) error { + b.config.User = args + return b.commit("", b.config.Cmd, fmt.Sprintf("USER %v", args)) +} + func (b *buildFile) CmdInsert(args string) error { return fmt.Errorf("INSERT has been deprecated. Please use ADD instead") } diff --git a/buildfile_test.go b/buildfile_test.go index d89c40d16c..14986161d8 100644 --- a/buildfile_test.go +++ b/buildfile_test.go @@ -270,6 +270,17 @@ func TestBuildMaintainer(t *testing.T) { } } +func TestBuildUser(t *testing.T) { + img := buildImage(testContextTemplate{` + from {IMAGE} + user dockerio + `, nil, nil}, t, nil, true) + + if img.Config.User != "dockerio" { + t.Fail() + } +} + func TestBuildEnv(t *testing.T) { img := buildImage(testContextTemplate{` from {IMAGE} diff --git a/docs/sources/use/builder.rst b/docs/sources/use/builder.rst index d111e335ab..98c6beaccb 100644 --- a/docs/sources/use/builder.rst +++ b/docs/sources/use/builder.rst @@ -203,6 +203,14 @@ to the entrypoint. The ``VOLUME`` instruction will add one or more new volumes to any container created from the image. +3.10 USER +--------- + + ``USER daemon`` + +The ``USER`` instruction sets the username or UID to use when running +the image. + 4. Dockerfile Examples ======================