Building Docker Images: Docker Build Command

The docker build command builds Docker images from a Dockerfile and a “context”. A build’s context is the set of files located in the specified PATH or URL. The build process can refer to any of the files in the context.

This triggers a single build manually.

Build an image from a Dockerfile

To build a Dockerfile you can call the Docker Build Command (docker build). For example, the following would run the file called Dockerfile, pass in the current Directory as the build Context and save the resulting image with name test and tag test-tag.

docker build -tag test:test-tag .

Alternatively, you could pass in a different Dockerfile (using -f command) and context (this always the last parameter – i.e.. ./src/):

docker build -f path-to-other/dockerfile ./src/

Example

If you were in the custom website root and ran the following command, it would call the Dockerfile in the root, pass in the contents of /src/ as the context, and create a local image with ‘latest’ tag:

docker build ./src/ -tag custom-sitecore-website:latest

Leave a Reply

Your email address will not be published. Required fields are marked *