1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add USER instruction

This commit is contained in:
Victor Vieux 2013-08-13 12:02:17 +00:00
parent f6760fca88
commit 5ee3c58d25
3 changed files with 24 additions and 0 deletions

View file

@ -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")
}

View file

@ -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}

View file

@ -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
======================