I'm migrating a few Docker containers between hosts and realised that one step that always needs to happen to any image is tagging – this will save you confusion and time in the future.
How Untagged Docker Images Look
Without tags, you just see the Docker Image IDs in the list – that's the only identifier you can use for spinning up Docker containers based on such images:
root@debian:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 174793a6cdeb 44 minutes ago 951MB 12fe92cbee30 44 minutes ago 367MB
How To Tag Docker Images
Although it's called tagging, technically this process allows you to specify a repository for your Docker image – effectively giving the image a name. If you want to specify that this is one of the many images belonging to a particular group or vendor, use / delimited notation like this:
unixtutorial/web-server
Where unixtutorial is a group or organisation (repository) and web-server is its subsection.
In my examples I'm using my consultancy codename – techstack: techstack/confluence for the wiki engine and techstack/db for my custom build of MariaDB.
Simply run the docker tag command, first parameter is the image ID and second is the repository (with optional tag, by default it will be tag called "latest"):
root@debian:~# docker tag 12fe92cbee30 techstack/db
root@debian:~# docker tag 174793a6cdeb techstack/confluence
You can tag or rename the same image more than once: in this case I'm tagging the same image with repository name techstack/confluence and tag "new":
root@debian:~# docker tag 174793a6cdeb techstack/confluence:new
How Tagged Docker Images Look
This is much better now:
root@debian:/storage/docker # docker images REPOSITORY TAG IMAGE ID CREATED SIZE techstack/confluence latest 174793a6cdeb 3 hours ago 951MB techstack/confluence new 174793a6cdeb 4 hours ago 951MB techstack/db latest 12fe92cbee30 3 hours ago 367MB
That's it for today!
Leave a Reply