Browse code

conert docker (commit|import|tag) to use REPOSITORY[:TAG] (and repove support for REPOSITORY TAG)

Sven Dowideit authored on 2013/10/30 15:26:13
Showing 2 changed files
... ...
@@ -904,7 +904,7 @@ func (cli *DockerCli) CmdKill(args ...string) error {
904 904
 }
905 905
 
906 906
 func (cli *DockerCli) CmdImport(args ...string) error {
907
-	cmd := Subcmd("import", "URL|- [REPOSITORY [TAG]]", "Create a new filesystem image from the contents of a tarball(.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz).")
907
+	cmd := Subcmd("import", "URL|- [REPOSITORY[:TAG]]", "Create a new filesystem image from the contents of a tarball(.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz).")
908 908
 
909 909
 	if err := cmd.Parse(args); err != nil {
910 910
 		return nil
... ...
@@ -913,7 +913,8 @@ func (cli *DockerCli) CmdImport(args ...string) error {
913 913
 		cmd.Usage()
914 914
 		return nil
915 915
 	}
916
-	src, repository, tag := cmd.Arg(0), cmd.Arg(1), cmd.Arg(2)
916
+	src := cmd.Arg(0)
917
+	repository, tag := utils.ParseRepositoryTag(cmd.Arg(1))
917 918
 	v := url.Values{}
918 919
 	v.Set("repo", repository)
919 920
 	v.Set("tag", tag)
... ...
@@ -1230,14 +1231,16 @@ func (cli *DockerCli) CmdPs(args ...string) error {
1230 1230
 }
1231 1231
 
1232 1232
 func (cli *DockerCli) CmdCommit(args ...string) error {
1233
-	cmd := Subcmd("commit", "[OPTIONS] CONTAINER [REPOSITORY [TAG]]", "Create a new image from a container's changes")
1233
+	cmd := Subcmd("commit", "[OPTIONS] CONTAINER [REPOSITORY[:TAG]]", "Create a new image from a container's changes")
1234 1234
 	flComment := cmd.String("m", "", "Commit message")
1235 1235
 	flAuthor := cmd.String("author", "", "Author (eg. \"John Hannibal Smith <hannibal@a-team.com>\"")
1236 1236
 	flConfig := cmd.String("run", "", "Config automatically applied when the image is run. "+`(ex: {"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')`)
1237 1237
 	if err := cmd.Parse(args); err != nil {
1238 1238
 		return nil
1239 1239
 	}
1240
-	name, repository, tag := cmd.Arg(0), cmd.Arg(1), cmd.Arg(2)
1240
+	name := cmd.Arg(0)
1241
+	repository, tag := utils.ParseRepositoryTag(cmd.Arg(1))
1242
+
1241 1243
 	if name == "" {
1242 1244
 		cmd.Usage()
1243 1245
 		return nil
... ...
@@ -1515,7 +1518,7 @@ func (opts PathOpts) Set(val string) error {
1515 1515
 }
1516 1516
 
1517 1517
 func (cli *DockerCli) CmdTag(args ...string) error {
1518
-	cmd := Subcmd("tag", "[OPTIONS] IMAGE REPOSITORY [TAG]", "Tag an image into a repository")
1518
+	cmd := Subcmd("tag", "[OPTIONS] IMAGE REPOSITORY[:TAG]", "Tag an image into a repository")
1519 1519
 	force := cmd.Bool("f", false, "Force")
1520 1520
 	if err := cmd.Parse(args); err != nil {
1521 1521
 		return nil
... ...
@@ -1526,10 +1529,10 @@ func (cli *DockerCli) CmdTag(args ...string) error {
1526 1526
 	}
1527 1527
 
1528 1528
 	v := url.Values{}
1529
-	v.Set("repo", cmd.Arg(1))
1530
-	if cmd.NArg() == 3 {
1531
-		v.Set("tag", cmd.Arg(2))
1532
-	}
1529
+	repository, tag := utils.ParseRepositoryTag(cmd.Arg(1))
1530
+
1531
+	v.Set("repo", repository)
1532
+	v.Set("tag", tag)
1533 1533
 
1534 1534
 	if *force {
1535 1535
 		v.Set("force", "1")
... ...
@@ -133,7 +133,6 @@ to the ``docker`` daemon.  ``ADD`` doesn't work when running in this
133 133
 mode because the absence of the context provides no source files to
134 134
 copy to the container.
135 135
 
136
-
137 136
 .. code-block:: bash
138 137
 
139 138
     sudo docker build github.com/creack/docker-firefox
... ...
@@ -151,7 +150,7 @@ by using the ``git://`` schema.
151 151
 
152 152
 ::
153 153
 
154
-    Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY [TAG]]
154
+    Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
155 155
 
156 156
     Create a new image from a container's changes
157 157
 
... ...
@@ -160,7 +159,26 @@ by using the ``git://`` schema.
160 160
       -run="": Configuration to be applied when the image is launched with `docker run`.
161 161
                (ex: '{"Cmd": ["cat", "/world"], "PortSpecs": ["22"]}')
162 162
 
163
-Full -run example (multiline is ok within a single quote ``'``)
163
+Simple commit of an existing container
164
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165
+
166
+.. code-block:: bash
167
+
168
+	$ docker ps
169
+	ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
170
+	c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours                             
171
+	197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours                             
172
+	$ docker commit c3f279d17e0a  SvenDowideit/testimage:version3
173
+	f5283438590d
174
+	$ docker images | head
175
+	REPOSITORY                        TAG                 ID                  CREATED             SIZE
176
+	SvenDowideit/testimage            version3            f5283438590d        16 seconds ago      204.2 MB (virtual 335.7 MB)
177
+	S
178
+
179
+Full -run example
180
+.................
181
+
182
+(multiline is ok within a single quote ``'``)
164 183
 
165 184
 ::
166 185
 
... ...
@@ -317,7 +335,7 @@ Displaying images visually
317 317
 
318 318
 ::
319 319
 
320
-    Usage: docker import URL|- [REPOSITORY [TAG]]
320
+    Usage: docker import URL|- [REPOSITORY[:TAG]]
321 321
 
322 322
     Create a new filesystem image from the contents of a tarball
323 323
 
... ...
@@ -333,14 +351,16 @@ Examples
333 333
 Import from a remote location
334 334
 .............................
335 335
 
336
-``$ sudo docker import http://example.com/exampleimage.tgz exampleimagerepo``
336
+This will create a new untagged image.
337
+
338
+``$ sudo docker import http://example.com/exampleimage.tgz``
337 339
 
338 340
 Import from a local file
339 341
 ........................
340 342
 
341 343
 Import to docker via pipe and standard in
342 344
 
343
-``$ cat exampleimage.tgz | sudo docker import - exampleimagelocal``
345
+``$ cat exampleimage.tgz | sudo docker import - exampleimagelocal:new``
344 346
 
345 347
 Import from a local directory
346 348
 .............................
... ...
@@ -716,7 +736,7 @@ The main process inside the container will receive SIGTERM, and after a grace pe
716 716
 
717 717
 ::
718 718
 
719
-    Usage: docker tag [OPTIONS] IMAGE REPOSITORY [TAG]
719
+    Usage: docker tag [OPTIONS] IMAGE REPOSITORY[:TAG]
720 720
 
721 721
     Tag an image into a repository
722 722