docker build

Command Name: 

docker build


docker  build command builds an image from a Dockerfile.

The docker build command builds Docker images from a Dockerfile and a “context”. A build’s context is nothing but the set of files and folders specified in the PATH or URL.


docker build [OPTIONS] PATH | URL | -


To use the docker build command below are the steps:

1. Create Dockerfile

2. Use docker build command to create the image

Dockerfile example: 

#This is a sample Image 
FROM ubuntu 
RUN apt-get update
RUN apt-get install curl wget 
RUN apt-get install -y nginx 
CMD ["echo","Image created successfully"]

Build the image from above Dockerfile

docker  build -t my-ubuntu .     

This example specifies that the PATH is “.” and so all the files in the local directory get tard and sent to the Docker daemon.