How to create named and latest tag in Docker?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Supposed I have an image that I want to tag as 0.10.24
(in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build
and by providing a tag using the -t
parameter.
I expect that one day I will have additional versions of that image, so I will rerun the process, just with another tag name.
So far, so good. This works great and fine and all is well.
But, and this is where problems start, I also want to always have the newest image tagged ad latest
additionally. So I guess I need to give two names to the very same image.
How do I do this? Do I really need to re-run docker build
on the exact same version again, but this time use another tag, is is there a better option?
docker tags
add a comment |
Supposed I have an image that I want to tag as 0.10.24
(in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build
and by providing a tag using the -t
parameter.
I expect that one day I will have additional versions of that image, so I will rerun the process, just with another tag name.
So far, so good. This works great and fine and all is well.
But, and this is where problems start, I also want to always have the newest image tagged ad latest
additionally. So I guess I need to give two names to the very same image.
How do I do this? Do I really need to re-run docker build
on the exact same version again, but this time use another tag, is is there a better option?
docker tags
Related question: stackoverflow.com/questions/21928780/…
– Mark Butler
Jan 19 '15 at 21:14
add a comment |
Supposed I have an image that I want to tag as 0.10.24
(in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build
and by providing a tag using the -t
parameter.
I expect that one day I will have additional versions of that image, so I will rerun the process, just with another tag name.
So far, so good. This works great and fine and all is well.
But, and this is where problems start, I also want to always have the newest image tagged ad latest
additionally. So I guess I need to give two names to the very same image.
How do I do this? Do I really need to re-run docker build
on the exact same version again, but this time use another tag, is is there a better option?
docker tags
Supposed I have an image that I want to tag as 0.10.24
(in my case it's an image containing Node.js 0.10.24). I built that image using a Dockerfile and executing docker build
and by providing a tag using the -t
parameter.
I expect that one day I will have additional versions of that image, so I will rerun the process, just with another tag name.
So far, so good. This works great and fine and all is well.
But, and this is where problems start, I also want to always have the newest image tagged ad latest
additionally. So I guess I need to give two names to the very same image.
How do I do this? Do I really need to re-run docker build
on the exact same version again, but this time use another tag, is is there a better option?
docker tags
docker tags
edited Jan 22 at 12:58
Martin Schröder
2,32932651
2,32932651
asked Feb 27 '14 at 21:22
Golo RodenGolo Roden
59.9k60212311
59.9k60212311
Related question: stackoverflow.com/questions/21928780/…
– Mark Butler
Jan 19 '15 at 21:14
add a comment |
Related question: stackoverflow.com/questions/21928780/…
– Mark Butler
Jan 19 '15 at 21:14
Related question: stackoverflow.com/questions/21928780/…
– Mark Butler
Jan 19 '15 at 21:14
Related question: stackoverflow.com/questions/21928780/…
– Mark Butler
Jan 19 '15 at 21:14
add a comment |
6 Answers
6
active
oldest
votes
You can have multiple tags when building the image:
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t
6
you can also leave off the:latest
portion, as that is the default:docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
add a comment |
Once you have your image, you can use
$ docker tag <image> <newName>/<repoName>:<tagName>
Build and tag the image with creack/node:latest
$ ID=$(docker build -q -t creack/node .)
Add a new tag
$ docker tag $ID creack/node:0.10.24
You can use this and skip the -t part from build
$ docker tag $ID creack/node:latest
4
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
13
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an imagecreack/node:latest
, you can then tag it withdocker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
This works well with something likeREV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
1
To make the latest tag work properly, you will probably want to dodocker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)
– treaz
Jun 25 '15 at 10:45
3
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
|
show 3 more comments
Here is my bash script
docker build -t ${IMAGE}:${VERSION} .
docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
You can then remove untagged images if you rebuilt the same version with
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
link
or
docker rmi $(docker images | grep "^<none>" | tr -s " " | cut -d' ' -f3 | tr 'n' ' ')
or
Clean up commands:
Docker 1.13 introduces clean-up commands. To remove all unused containers, images, networks and volumes:
docker system prune
or individually:
docker container prune
docker image prune
docker network prune
docker volume prune
On my machine (Ubuntu 14.04)awk '{print $3}'
works but notawk "{print $3}"
so the command I use isdocker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
1
the-f
option no longer exists indocker tag
. Usage is justdocker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
@2Fast2BCn: Assuming you also need todocker push
afterdocker build & docker run
, do you push with:latest
or${VERSION}
?
– Idan Adar
Jun 19 '17 at 9:11
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
add a comment |
ID=$(docker build -t creack/node .)
doesn't work for me since ID
will contain the output from the build.
SO I'm using this small BASH script:
#!/bin/bash
set -o pipefail
IMAGE=...your image name...
VERSION=...the version...
docker build -t ${IMAGE}:${VERSION} . | tee build.log || exit 1
ID=$(tail -1 build.log | awk '{print $3;}')
docker tag $ID ${IMAGE}:latest
docker images | grep ${IMAGE}
docker run --rm ${IMAGE}:latest /opt/java7/bin/java -version
Or you can just pass-q
/--quiet
tobuild
as mentioned in this answer
– hangtwenty
Feb 13 '17 at 19:22
add a comment |
Just grep the ID from docker images
:
docker build -t creack/node:latest .
ID="$(docker images | grep 'creak/node' | head -n 1 | awk '{print $3}')"
docker tag "$ID" creack/node:0.10.24
docker tag "$ID" creack/node:latest
Needs no temporary file and gives full build output. You still can redirect it to /dev/null
or a log file.
add a comment |
Variation of Aaron's answer.
Using sed without temporary files
#!/bin/bash
VERSION=1.0.0
IMAGE=company/image
ID=$(docker build -t ${IMAGE} . | tail -1 | sed 's/.*Successfully built (.*)$/1/')
docker tag ${ID} ${IMAGE}:${VERSION}
docker tag -f ${ID} ${IMAGE}:latest
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22080706%2fhow-to-create-named-and-latest-tag-in-docker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can have multiple tags when building the image:
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t
6
you can also leave off the:latest
portion, as that is the default:docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
add a comment |
You can have multiple tags when building the image:
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t
6
you can also leave off the:latest
portion, as that is the default:docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
add a comment |
You can have multiple tags when building the image:
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t
You can have multiple tags when building the image:
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
Reference: https://docs.docker.com/engine/reference/commandline/build/#tag-image-t
answered Apr 4 '16 at 8:57
TommyTommy
3,42032225
3,42032225
6
you can also leave off the:latest
portion, as that is the default:docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
add a comment |
6
you can also leave off the:latest
portion, as that is the default:docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
6
6
you can also leave off the
:latest
portion, as that is the default: docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
you can also leave off the
:latest
portion, as that is the default: docker build -t whenry/fedora-jboss -t whenry/fedora-jboss:v2.1 .
– TemporalWolf
Mar 20 '18 at 21:20
add a comment |
Once you have your image, you can use
$ docker tag <image> <newName>/<repoName>:<tagName>
Build and tag the image with creack/node:latest
$ ID=$(docker build -q -t creack/node .)
Add a new tag
$ docker tag $ID creack/node:0.10.24
You can use this and skip the -t part from build
$ docker tag $ID creack/node:latest
4
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
13
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an imagecreack/node:latest
, you can then tag it withdocker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
This works well with something likeREV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
1
To make the latest tag work properly, you will probably want to dodocker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)
– treaz
Jun 25 '15 at 10:45
3
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
|
show 3 more comments
Once you have your image, you can use
$ docker tag <image> <newName>/<repoName>:<tagName>
Build and tag the image with creack/node:latest
$ ID=$(docker build -q -t creack/node .)
Add a new tag
$ docker tag $ID creack/node:0.10.24
You can use this and skip the -t part from build
$ docker tag $ID creack/node:latest
4
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
13
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an imagecreack/node:latest
, you can then tag it withdocker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
This works well with something likeREV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
1
To make the latest tag work properly, you will probably want to dodocker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)
– treaz
Jun 25 '15 at 10:45
3
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
|
show 3 more comments
Once you have your image, you can use
$ docker tag <image> <newName>/<repoName>:<tagName>
Build and tag the image with creack/node:latest
$ ID=$(docker build -q -t creack/node .)
Add a new tag
$ docker tag $ID creack/node:0.10.24
You can use this and skip the -t part from build
$ docker tag $ID creack/node:latest
Once you have your image, you can use
$ docker tag <image> <newName>/<repoName>:<tagName>
Build and tag the image with creack/node:latest
$ ID=$(docker build -q -t creack/node .)
Add a new tag
$ docker tag $ID creack/node:0.10.24
You can use this and skip the -t part from build
$ docker tag $ID creack/node:latest
edited Jan 3 at 9:19
Shubham
2,01821528
2,01821528
answered Feb 27 '14 at 21:52
creackcreack
70.6k107263
70.6k107263
4
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
13
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an imagecreack/node:latest
, you can then tag it withdocker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
This works well with something likeREV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
1
To make the latest tag work properly, you will probably want to dodocker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)
– treaz
Jun 25 '15 at 10:45
3
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
|
show 3 more comments
4
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
13
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an imagecreack/node:latest
, you can then tag it withdocker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
This works well with something likeREV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
1
To make the latest tag work properly, you will probably want to dodocker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)
– treaz
Jun 25 '15 at 10:45
3
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
4
4
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
This doesn't seem to work anymore? The build command doesn't return the image id, ID contains the entire build log
– Nicolas Mommaerts
Jul 24 '14 at 11:09
13
13
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an image
creack/node:latest
, you can then tag it with docker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
The build logs are supposed to be on stderr, you can open a bugreport on github. Otherwise, when you build with -t, you can use directly the given tag and discard altogether the image id. In my example, the first line produce an image
creack/node:latest
, you can then tag it with docker tag creack/node:latest creack/node:0.10.24
– creack
Jul 24 '14 at 11:12
This works well with something like
REV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
This works well with something like
REV=$(hg identify --num)
– analytik
Jun 3 '15 at 13:41
1
1
To make the latest tag work properly, you will probably want to do
docker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)– treaz
Jun 25 '15 at 10:45
To make the latest tag work properly, you will probably want to do
docker tag -f $ID creack/node:latest
in order to force the tagging with latest (in case a previous image was already latest)– treaz
Jun 25 '15 at 10:45
3
3
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
Use: ID=$(docker build -q -t myrepo/myname:mytag . ) . The "-q" means only the ID is written to stdout. You should always specify a tag, as if you don't the tag 'latest' will be used, even if you are building of an old branch.
– David Roussel
Feb 10 '16 at 11:44
|
show 3 more comments
Here is my bash script
docker build -t ${IMAGE}:${VERSION} .
docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
You can then remove untagged images if you rebuilt the same version with
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
link
or
docker rmi $(docker images | grep "^<none>" | tr -s " " | cut -d' ' -f3 | tr 'n' ' ')
or
Clean up commands:
Docker 1.13 introduces clean-up commands. To remove all unused containers, images, networks and volumes:
docker system prune
or individually:
docker container prune
docker image prune
docker network prune
docker volume prune
On my machine (Ubuntu 14.04)awk '{print $3}'
works but notawk "{print $3}"
so the command I use isdocker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
1
the-f
option no longer exists indocker tag
. Usage is justdocker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
@2Fast2BCn: Assuming you also need todocker push
afterdocker build & docker run
, do you push with:latest
or${VERSION}
?
– Idan Adar
Jun 19 '17 at 9:11
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
add a comment |
Here is my bash script
docker build -t ${IMAGE}:${VERSION} .
docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
You can then remove untagged images if you rebuilt the same version with
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
link
or
docker rmi $(docker images | grep "^<none>" | tr -s " " | cut -d' ' -f3 | tr 'n' ' ')
or
Clean up commands:
Docker 1.13 introduces clean-up commands. To remove all unused containers, images, networks and volumes:
docker system prune
or individually:
docker container prune
docker image prune
docker network prune
docker volume prune
On my machine (Ubuntu 14.04)awk '{print $3}'
works but notawk "{print $3}"
so the command I use isdocker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
1
the-f
option no longer exists indocker tag
. Usage is justdocker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
@2Fast2BCn: Assuming you also need todocker push
afterdocker build & docker run
, do you push with:latest
or${VERSION}
?
– Idan Adar
Jun 19 '17 at 9:11
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
add a comment |
Here is my bash script
docker build -t ${IMAGE}:${VERSION} .
docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
You can then remove untagged images if you rebuilt the same version with
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
link
or
docker rmi $(docker images | grep "^<none>" | tr -s " " | cut -d' ' -f3 | tr 'n' ' ')
or
Clean up commands:
Docker 1.13 introduces clean-up commands. To remove all unused containers, images, networks and volumes:
docker system prune
or individually:
docker container prune
docker image prune
docker network prune
docker volume prune
Here is my bash script
docker build -t ${IMAGE}:${VERSION} .
docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
You can then remove untagged images if you rebuilt the same version with
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
link
or
docker rmi $(docker images | grep "^<none>" | tr -s " " | cut -d' ' -f3 | tr 'n' ' ')
or
Clean up commands:
Docker 1.13 introduces clean-up commands. To remove all unused containers, images, networks and volumes:
docker system prune
or individually:
docker container prune
docker image prune
docker network prune
docker volume prune
edited Jan 3 at 10:42
Shubham
2,01821528
2,01821528
answered Jan 16 '15 at 16:05
2Fast2BCn2Fast2BCn
46649
46649
On my machine (Ubuntu 14.04)awk '{print $3}'
works but notawk "{print $3}"
so the command I use isdocker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
1
the-f
option no longer exists indocker tag
. Usage is justdocker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
@2Fast2BCn: Assuming you also need todocker push
afterdocker build & docker run
, do you push with:latest
or${VERSION}
?
– Idan Adar
Jun 19 '17 at 9:11
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
add a comment |
On my machine (Ubuntu 14.04)awk '{print $3}'
works but notawk "{print $3}"
so the command I use isdocker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
1
the-f
option no longer exists indocker tag
. Usage is justdocker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
@2Fast2BCn: Assuming you also need todocker push
afterdocker build & docker run
, do you push with:latest
or${VERSION}
?
– Idan Adar
Jun 19 '17 at 9:11
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
On my machine (Ubuntu 14.04)
awk '{print $3}'
works but not awk "{print $3}"
so the command I use is docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
On my machine (Ubuntu 14.04)
awk '{print $3}'
works but not awk "{print $3}"
so the command I use is docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
– grim
Mar 23 '16 at 22:06
1
1
the
-f
option no longer exists in docker tag
. Usage is just docker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
the
-f
option no longer exists in docker tag
. Usage is just docker tag IMAGE[:TAG] IMAGE[:TAG]
– jwadsack
Oct 26 '16 at 0:11
@2Fast2BCn: Assuming you also need to
docker push
after docker build & docker run
, do you push with :latest
or ${VERSION}
?– Idan Adar
Jun 19 '17 at 9:11
@2Fast2BCn: Assuming you also need to
docker push
after docker build & docker run
, do you push with :latest
or ${VERSION}
?– Idan Adar
Jun 19 '17 at 9:11
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
You can push both I guess. It will store it only once anyway.
– 2Fast2BCn
Jun 19 '17 at 9:41
add a comment |
ID=$(docker build -t creack/node .)
doesn't work for me since ID
will contain the output from the build.
SO I'm using this small BASH script:
#!/bin/bash
set -o pipefail
IMAGE=...your image name...
VERSION=...the version...
docker build -t ${IMAGE}:${VERSION} . | tee build.log || exit 1
ID=$(tail -1 build.log | awk '{print $3;}')
docker tag $ID ${IMAGE}:latest
docker images | grep ${IMAGE}
docker run --rm ${IMAGE}:latest /opt/java7/bin/java -version
Or you can just pass-q
/--quiet
tobuild
as mentioned in this answer
– hangtwenty
Feb 13 '17 at 19:22
add a comment |
ID=$(docker build -t creack/node .)
doesn't work for me since ID
will contain the output from the build.
SO I'm using this small BASH script:
#!/bin/bash
set -o pipefail
IMAGE=...your image name...
VERSION=...the version...
docker build -t ${IMAGE}:${VERSION} . | tee build.log || exit 1
ID=$(tail -1 build.log | awk '{print $3;}')
docker tag $ID ${IMAGE}:latest
docker images | grep ${IMAGE}
docker run --rm ${IMAGE}:latest /opt/java7/bin/java -version
Or you can just pass-q
/--quiet
tobuild
as mentioned in this answer
– hangtwenty
Feb 13 '17 at 19:22
add a comment |
ID=$(docker build -t creack/node .)
doesn't work for me since ID
will contain the output from the build.
SO I'm using this small BASH script:
#!/bin/bash
set -o pipefail
IMAGE=...your image name...
VERSION=...the version...
docker build -t ${IMAGE}:${VERSION} . | tee build.log || exit 1
ID=$(tail -1 build.log | awk '{print $3;}')
docker tag $ID ${IMAGE}:latest
docker images | grep ${IMAGE}
docker run --rm ${IMAGE}:latest /opt/java7/bin/java -version
ID=$(docker build -t creack/node .)
doesn't work for me since ID
will contain the output from the build.
SO I'm using this small BASH script:
#!/bin/bash
set -o pipefail
IMAGE=...your image name...
VERSION=...the version...
docker build -t ${IMAGE}:${VERSION} . | tee build.log || exit 1
ID=$(tail -1 build.log | awk '{print $3;}')
docker tag $ID ${IMAGE}:latest
docker images | grep ${IMAGE}
docker run --rm ${IMAGE}:latest /opt/java7/bin/java -version
answered Nov 5 '14 at 11:00
Aaron DigullaAaron Digulla
250k87480700
250k87480700
Or you can just pass-q
/--quiet
tobuild
as mentioned in this answer
– hangtwenty
Feb 13 '17 at 19:22
add a comment |
Or you can just pass-q
/--quiet
tobuild
as mentioned in this answer
– hangtwenty
Feb 13 '17 at 19:22
Or you can just pass
-q
/ --quiet
to build
as mentioned in this answer– hangtwenty
Feb 13 '17 at 19:22
Or you can just pass
-q
/ --quiet
to build
as mentioned in this answer– hangtwenty
Feb 13 '17 at 19:22
add a comment |
Just grep the ID from docker images
:
docker build -t creack/node:latest .
ID="$(docker images | grep 'creak/node' | head -n 1 | awk '{print $3}')"
docker tag "$ID" creack/node:0.10.24
docker tag "$ID" creack/node:latest
Needs no temporary file and gives full build output. You still can redirect it to /dev/null
or a log file.
add a comment |
Just grep the ID from docker images
:
docker build -t creack/node:latest .
ID="$(docker images | grep 'creak/node' | head -n 1 | awk '{print $3}')"
docker tag "$ID" creack/node:0.10.24
docker tag "$ID" creack/node:latest
Needs no temporary file and gives full build output. You still can redirect it to /dev/null
or a log file.
add a comment |
Just grep the ID from docker images
:
docker build -t creack/node:latest .
ID="$(docker images | grep 'creak/node' | head -n 1 | awk '{print $3}')"
docker tag "$ID" creack/node:0.10.24
docker tag "$ID" creack/node:latest
Needs no temporary file and gives full build output. You still can redirect it to /dev/null
or a log file.
Just grep the ID from docker images
:
docker build -t creack/node:latest .
ID="$(docker images | grep 'creak/node' | head -n 1 | awk '{print $3}')"
docker tag "$ID" creack/node:0.10.24
docker tag "$ID" creack/node:latest
Needs no temporary file and gives full build output. You still can redirect it to /dev/null
or a log file.
edited Sep 8 '15 at 11:59
answered Aug 25 '15 at 15:03


Pierre-Alexis de SolminihacPierre-Alexis de Solminihac
1,3302713
1,3302713
add a comment |
add a comment |
Variation of Aaron's answer.
Using sed without temporary files
#!/bin/bash
VERSION=1.0.0
IMAGE=company/image
ID=$(docker build -t ${IMAGE} . | tail -1 | sed 's/.*Successfully built (.*)$/1/')
docker tag ${ID} ${IMAGE}:${VERSION}
docker tag -f ${ID} ${IMAGE}:latest
add a comment |
Variation of Aaron's answer.
Using sed without temporary files
#!/bin/bash
VERSION=1.0.0
IMAGE=company/image
ID=$(docker build -t ${IMAGE} . | tail -1 | sed 's/.*Successfully built (.*)$/1/')
docker tag ${ID} ${IMAGE}:${VERSION}
docker tag -f ${ID} ${IMAGE}:latest
add a comment |
Variation of Aaron's answer.
Using sed without temporary files
#!/bin/bash
VERSION=1.0.0
IMAGE=company/image
ID=$(docker build -t ${IMAGE} . | tail -1 | sed 's/.*Successfully built (.*)$/1/')
docker tag ${ID} ${IMAGE}:${VERSION}
docker tag -f ${ID} ${IMAGE}:latest
Variation of Aaron's answer.
Using sed without temporary files
#!/bin/bash
VERSION=1.0.0
IMAGE=company/image
ID=$(docker build -t ${IMAGE} . | tail -1 | sed 's/.*Successfully built (.*)$/1/')
docker tag ${ID} ${IMAGE}:${VERSION}
docker tag -f ${ID} ${IMAGE}:latest
answered Jul 30 '15 at 13:42
TonyTony
8621116
8621116
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22080706%2fhow-to-create-named-and-latest-tag-in-docker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Related question: stackoverflow.com/questions/21928780/…
– Mark Butler
Jan 19 '15 at 21:14