Image building runs the Dockerfile with docker build, from a context of files. A .dockerignore file excludes what is useless or sensitive (local dependencies, secrets), which speeds up the build and lightens the image.
Example
docker build -t mon-app:1.0 .