A Dockerfile is a script/text configuration file that contains collections of commands and instructions that will be automatically executed in sequence in the docker environment for building a new docker image.This file is written in a popular, human-readable Markup Language called YAML.
The docker build command processes this file generating a Docker Image in your Local Image Cache, which you can then start-up using the docker run command, or push to a permanent Image Repository.
We will create a new directory for the dockerfile and define what we want to do with that dockerfile.
- Create a new directory and a new and empty dockerfile inside that directory.
- Now Add a few docker commands in your docker file
RUN apt-get update
RUN apt-get install vim -y
CMD /bin/echo "Hello! Welcome to docker Tutorial!!!"
- Now the next step is to build the dockerfile to get the docker image.To do this, Run the following command, here "devopstrainer" is the tag name "ubuntu" is image name with a tag "dockerfile", inorder to understand that this image is created using a dockerfile:
docker build -t devopstrainer/ubuntu:dockerfile .
- Your docker image would be successfully created. Verify this by running the command: