Essential Docker build commands with explanations and examples
| Command | Description | Action |
|---|---|---|
| docker build -t [name:tag] . | Builds an image using a Dockerfile located in the same folder | |
| docker build -t [name:tag] -f [fileName] | Builds an image using a Dockerfile located in a different folder | |
| docker tag [imageName] [name:tag] | Tag an existing image |
Use descriptive names and tags for your images. A good practice is to use:
username/repository:tag
When using -f flag, specify the path to your Dockerfile. The build context (.) is still important for copying files.