We created our Docker File in the last chapter. Itβs now time to building the Docker File. The Docker File can be built with the following command β
docker build
Letβs learn more about this command.
docker build
This method allows the users to build their own Docker images.
Syntax
docker build -t ImageName:TagName dir
Options
- -t β is to mention a tag to the image
- ImageName β This is the name you want to give to your image.
- TagName β This is the tag you want to give to your image.
- Dir β The directory where the Docker File is present.
Return Value
None
Example
sudo docker build βt myimage:0.1.
Here, myimage is the name we are giving to the Image and 0.1 is the tag number we are giving to our image.
Since the Docker File is in the present working directory, we used “.” at the end of the command to signify the present working directory.
Output
From the output, you will first see that the Ubuntu Image will be downloaded from Docker Hub, because there is no image available locally on the machine.
Finally, when the build is complete, all the necessary commands would have run on the image.
You will then see the successfully built message and the ID of the new Image. When you run the Docker images command, you would then be able to see your new image.
You can now build containers from your new Image.
In this topic, we learnt about building the Docker File to know more click here.
Pingback: Docker - Setting NGINX - Adglob Infosystem Pvt Ltd