1. Introduction
In this article, we will explain Docker Tag with examples. A Docker tag is a named reference to an image. It is like a branch reference in Git. This tag can be used to pull and run images. The updates to the images can be pushed automatically like in Git.
2. Docker Tag
Docker is used in DevOps as a software package to create containers for deployment. It helps in handling changes in code, requirements, operating systems, and cloud environments. Tags help in identifying the images and the derived images. You can go to Docker Hub and choose a tag to pull the image. The latest version will be pushed to the Docker Hub by the authors.
2.1 Prerequisites
Docker
software is required. Apache Tomcat image is obtained from Docker Hub
.
2.2 Download
You can download Docker
from the site.
2.3 Setup for Docker
Below is the setup check commands after installing the docker package
.
You can check the docker installation by running the hello-world docker repo which is located at the docker hub.
Docker Hello-World
docker run hello-world
The output of the above command will be as below:
Output
Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
2.4 Docker
You can create your own Repo and images. Dockerfile details are shown below: Dockerfile
The command to create docker
is shown below:
Docker File
FROM busybox CMD echo "Greetings! Docker image is created."
The output of the docker build command will be as below:
Docker Repo creation Output
docker build -t bhagvanarch/docker-repo . Sending build context to Docker daemon 2.048kB Step 1/2 : FROM busybox latest: Pulling from library/busybox 76df9210b28c: Pull complete Digest: sha256:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209 Status: Downloaded newer image for busybox:latest ---> 1c35c4412082 Step 2/2 : CMD echo "Greetings! Docker image is created." ---> Running in bc9f0d8ac3d7 Removing intermediate container bc9f0d8ac3d7 ---> 166dae6f16f8 Successfully built 166dae6f16f8 Successfully tagged bhagvanarch/docker-repo:latest