Monday 27 May 2019

Docker: Create an image that refers to other image


Using 'docker image tag' command, you can create a tag that refers to another tag.

Syntax
docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

$docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tagsapp             1                   17ff919cfdbd        6 minutes ago       88.9MB
tagsapp             latest              a1868b148d8d        14 minutes ago      88.9MB
ubuntu              latest              94e814e2efa8        6 weeks ago         88.9MB

As you see above output, I have three images tagsapp:latest, tagsapp:1, ubuntu:latest.


Let me run and see the output of tagsapp image.

$docker run tagsapp:latest
Image without tag
$
$docker run tagsapp:1
Application version 1

I would like to create a tag ‘tagsapp:2’ from ‘tagsapp:1’ by executing below command.


docker image tag tagsapp:1 tagsapp:2

$docker image tag tagsapp:1 tagsapp:2
$
$docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tagsapp             1                   17ff919cfdbd        8 minutes ago       88.9MB
tagsapp             2                   17ff919cfdbd        8 minutes ago       88.9MB
tagsapp             latest              a1868b148d8d        17 minutes ago      88.9MB
ubuntu              latest              94e814e2efa8        6 weeks ago         88.9MB
hello-world         latest              fce289e99eb9        3 months ago        1.84kB
hello-world         linux               fce289e99eb9        3 months ago        1.84kB
$
$docker run tagsapp:2
Application version 1




Previous                                                 Next                                                 Home

No comments:

Post a Comment