# Building an Image — Docker

Source: https://www.geekswithgeeks.com/en/docker/docker-build

> docker build turns a Dockerfile into a runnable image.

## docker build

`-t` tags the image with a name. The trailing `.` is the **build context** — the directory Docker can see and copy from.

```bash
docker build -t my-app:1.0 .
docker run -d my-app:1.0
```

## Layers & caching

Each instruction creates a **layer**. Docker caches layers and reuses them if nothing above them changed — that's why copying `package.json` and running `npm install` **before** copying the rest of the code speeds up rebuilds.
