build command is used to build an image from a Dockerfile, but the command has to be run in the same directory as the Dockerfile.
When an image is built, the commands specified in the Dockerfile are executed. The operating system is installed along with all the packages required in the Docker container. Because of this, Docker images can often take up a large amount of space.
build command is run on the command-line using the following syntax:
docker build <options> <directory path or URL>
directory path will be the address of the directory where we want to set up our container.
We can also provide a Git URL instead.
If we want to include all the files/folders that are in the same directory as the Dockerfile, we can build the image like this:
docker build .
. operator specifies the current directory.
options component allows us to add different pieces of information to the build command in order to run the container correctly – options will vary depending on the requirement of the container. The full list of options can be found [here](https://docs.docker.com/engine/reference/commandline/build/.
The directory in which the Docker image is built (i.e., the path provided in the
build command) becomes the Docker build context. This is the root directory of our Docker container. The memory outside of this directory is inaccessible in the container.
In other words, all the data within the build context is available in the container.