I have the following config:
docker {
name 'my-company/my-image'
tags project.version, 'latest'
dockerfile file('src/main/docker/Dockerfile')
dependsOn assemble
files jar
}
If I remove all images from my local machine other then the base image and then do:
$ gradle clean dockerPush
> Task :rest-service:dockerPush
The push refers to a repository [docker.io/my-company/my-image]
07cb7e265fa0: Preparing
762429e05518: Preparing
2be465c0fdf6: Preparing
5bef08742407: Preparing
2be465c0fdf6: Layer already exists
5bef08742407: Layer already exists
762429e05518: Layer already exists
07cb7e265fa0: Pushed
latest: digest: sha256:09ae39c3379061413cc450148fdb32baa2b07616fed5341df542595b3eb08b5f size: 1154
BUILD SUCCESSFUL in 10s
11 actionable tasks: 8 executed, 3 up-to-date
Notice however that only an image with the latest tag is created, so naturally that was all that was pushed:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-company/my-image latest c588bc51ad2e 7 seconds ago 81.4MB
openjdk 8u131-jre-alpine e2f6fe2dacef 5 weeks ago 81.4MB
To continue the example, I remove the image just created as such:
$ docker rmi c588bc51ad2e
Untagged: my-company/my-image:latest
Untagged: my-company/my-image@sha256:09ae39c3379061413cc450148fdb32baa2b07616fed5341df542595b3eb08b5f
Deleted: sha256:c588bc51ad2e5019176b09377fa9b15caa92216f6540dfb880c914dbafb69e47
Deleted: sha256:63d4d33b985b3ef47804d7e25cea23d91f4bef88a69168da2b54721aadd5eb97
Deleted: sha256:595c32029464585e6871fc32d075f12e4a175bae5c9d016c9fa9e6fc8975168c
Deleted: sha256:46e42747ee2fd820e49b90be14f066bdee60d589ca914eaf937df5aec811e037
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
openjdk 8u131-jre-alpine e2f6fe2dacef 5 weeks ago 81.4MB
And then run dockerTag first I get both tags and then dockerPush both are then pushed as shown here:
$ gradle clean dockerTag
BUILD SUCCESSFUL in 2s
12 actionable tasks: 9 executed, 3 up-to-date
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-company/my-image 0.1.24 3b1e1562402f Less than a second ago 81.4MB
my-company/my-image latest 3b1e1562402f Less than a second ago 81.4MB
openjdk 8u131-jre-alpine e2f6fe2dacef 5 weeks ago 81.4MB
$ gradle dockerPush
> Task :rest-service:dockerPush
The push refers to a repository [docker.io/my-company/my-image]
e13e5448aea4: Preparing
762429e05518: Preparing
2be465c0fdf6: Preparing
5bef08742407: Preparing
2be465c0fdf6: Layer already exists
5bef08742407: Layer already exists
762429e05518: Layer already exists
e13e5448aea4: Pushed
0.1.24: digest: sha256:129ecb7f1ed98f799ea44849b5a72beb79064d15f8484e2dcb37344a105df9a7 size: 1154
e13e5448aea4: Preparing
762429e05518: Preparing
2be465c0fdf6: Preparing
5bef08742407: Preparing
2be465c0fdf6: Layer already exists
5bef08742407: Layer already exists
762429e05518: Layer already exists
e13e5448aea4: Layer already exists
latest: digest: sha256:129ecb7f1ed98f799ea44849b5a72beb79064d15f8484e2dcb37344a105df9a7 size: 1154
BUILD SUCCESSFUL in 8s
8 actionable tasks: 5 executed, 3 up-to-date
Is there a trick to getting dockerPush to generate both tags, so that you can push them in one command?
I have the following config:
If I remove all images from my local machine other then the base image and then do:
Notice however that only an image with the
latesttag is created, so naturally that was all that was pushed:To continue the example, I remove the image just created as such:
And then run
dockerTagfirst I get both tags and thendockerPushboth are then pushed as shown here:Is there a trick to getting
dockerPushto generate both tags, so that you can push them in one command?