Browse code

Add USER instruction

Victor Vieux authored on 2013/08/13 21:02:17
Showing 3 changed files
... ...
@@ -197,6 +197,11 @@ func (b *buildFile) CmdExpose(args string) error {
197 197
 	return b.commit("", b.config.Cmd, fmt.Sprintf("EXPOSE %v", ports))
198 198
 }
199 199
 
200
+func (b *buildFile) CmdUser(args string) error {
201
+	b.config.User = args
202
+	return b.commit("", b.config.Cmd, fmt.Sprintf("USER %v", args))
203
+}
204
+
200 205
 func (b *buildFile) CmdInsert(args string) error {
201 206
 	return fmt.Errorf("INSERT has been deprecated. Please use ADD instead")
202 207
 }
... ...
@@ -270,6 +270,17 @@ func TestBuildMaintainer(t *testing.T) {
270 270
 	}
271 271
 }
272 272
 
273
+func TestBuildUser(t *testing.T) {
274
+	img := buildImage(testContextTemplate{`
275
+        from {IMAGE}
276
+        user dockerio
277
+    `, nil, nil}, t, nil, true)
278
+
279
+	if img.Config.User != "dockerio" {
280
+		t.Fail()
281
+	}
282
+}
283
+
273 284
 func TestBuildEnv(t *testing.T) {
274 285
 	img := buildImage(testContextTemplate{`
275 286
         from {IMAGE}
... ...
@@ -203,6 +203,14 @@ to the entrypoint.
203 203
 The ``VOLUME`` instruction will add one or more new volumes to any
204 204
 container created from the image.
205 205
 
206
+3.10 USER
207
+---------
208
+
209
+    ``USER daemon``
210
+
211
+The ``USER`` instruction sets the username or UID to use when running
212
+the image.
213
+
206 214
 4. Dockerfile Examples
207 215
 ======================
208 216