From 9d9976ae3a6129ce34d55865b501be9ab429d141 Mon Sep 17 00:00:00 2001 From: Shijiang Wei Date: Sun, 30 Aug 2015 21:48:03 +0800 Subject: [PATCH] Add ability to add multiple tags with docker build Signed-off-by: Shijiang Wei --- docs/reference/builder.md | 5 +++++ docs/reference/commandline/build.md | 10 +++++++++- man/docker-build.1.md | 12 ++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/docs/reference/builder.md b/docs/reference/builder.md index c65f34c308..b1ed35ded2 100644 --- a/docs/reference/builder.md +++ b/docs/reference/builder.md @@ -62,6 +62,11 @@ the build succeeds: $ docker build -t shykes/myapp . +To tag the image into multiple repositories after the build, +add multiple `-t` parameters when you run the `build` command: + + $ docker build -t shykes/myapp:1.0.2 -t shykes/myapp:latest . + The Docker daemon runs the instructions in the `Dockerfile` one-by-one, committing the result of each instruction to a new image if necessary, before finally outputting the ID of your diff --git a/docs/reference/commandline/build.md b/docs/reference/commandline/build.md index 23a34581f0..32a51ceb8b 100644 --- a/docs/reference/commandline/build.md +++ b/docs/reference/commandline/build.md @@ -31,7 +31,7 @@ parent = "smn_cli" --pull=false Always attempt to pull a newer version of the image -q, --quiet=false Suppress the verbose output generated by the containers --rm=true Remove intermediate containers after a successful build - -t, --tag="" Repository name (and optionally a tag) for the image + -t, --tag=[] Name and optionally a tag in the 'name:tag' format --ulimit=[] Ulimit options Builds Docker images from a Dockerfile and a "context". A build's context is @@ -227,6 +227,14 @@ uploaded context. The builder reference contains detailed information on This will build like the previous example, but it will then tag the resulting image. The repository name will be `vieux/apache` and the tag will be `2.0` +You can apply multiple tags to an image. For example, you can apply the `latest` +tag to a newly built image and add another tag that references a specific +version. +For example, to tag an image both as `whenry/fedora-jboss:latest` and +`whenry/fedora-jboss:v2.1`, use the following: + + $ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 . + ### Specify Dockerfile (-f) $ docker build -f Dockerfile.debug . diff --git a/man/docker-build.1.md b/man/docker-build.1.md index 876d6fa9bb..4bf4deea59 100644 --- a/man/docker-build.1.md +++ b/man/docker-build.1.md @@ -16,7 +16,7 @@ docker-build - Build a new image from the source code at PATH [**--pull**[=*false*]] [**-q**|**--quiet**[=*false*]] [**--rm**[=*true*]] -[**-t**|**--tag**[=*TAG*]] +[**-t**|**--tag**[=*[]*]] [**-m**|**--memory**[=*MEMORY*]] [**--memory-swap**[=*MEMORY-SWAP*]] [**--cpu-period**[=*0*]] @@ -82,7 +82,7 @@ set as the **URL**, the repository is cloned locally and then sent as the contex Remove intermediate containers after a successful build. The default is *true*. **-t**, **--tag**="" - Repository name (and optionally a tag) to be applied to the resulting image in case of success + Repository names (and optionally with tags) to be applied to the resulting image in case of success. **-m**, **--memory**=*MEMORY* Memory limit @@ -235,6 +235,14 @@ If you do not provide a version tag then Docker will assign `latest`: When you list the images, the image above will have the tag `latest`. +You can apply multiple tags to an image. For example, you can apply the `latest` +tag to a newly built image and add another tag that references a specific +version. +For example, to tag an image both as `whenry/fedora-jboss:latest` and +`whenry/fedora-jboss:v2.1`, use the following: + + docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 . + So renaming an image is arbitrary but consideration should be given to a useful convention that makes sense for consumers and should also take into account Docker community conventions.