=> [internal] load build definition from Dockerfile
=> CACHED [2/5] RUN apt-get update
=> [3/5] COPY package*.json ./
=> exporting to image
=> naming to docker.io/library/myapp:1.0
Note The dot at the end is the build context — Docker sends that entire directory to the daemon. Use .dockerignore to exclude node_modules and other heavy directories, or your builds will be painfully slow.
Note You cannot remove an image that has running or stopped containers using it. Stop and remove those containers first, or use -f to force removal.
remove imagedelete imageclean up imagesfree disk space
Prune Unused Images
syntax
docker image prune [options]
example
docker image prune
docker image prune -a --filter 'until=168h'
output
Total reclaimed space: 2.3GB
Note Without -a, this only removes dangling images (untagged). With -a, it removes ALL images not used by any container — this can delete base images you pulled but have not yet run. Use with caution.
prune imagesclean imagesremove unused imagesreclaim disk space
Note The output is JSON. Use --format with Go templates to extract specific fields like environment variables, labels, or exposed ports.
inspect imageimage detailsimage metadatashow image info
View Image Layer History
syntax
docker history <image>
example
docker history myapp:1.0docker history --no-trunc myapp:1.0
output
IMAGE CREATED BY SIZE
a1b2c3d4e5f6 CMD ["node" "server.js"] 0B
<missing> COPY . /app 45MB
<missing> RUN npm ci --omit=dev 85MB
Note This shows each layer and the command that created it. Great for diagnosing why an image is larger than expected — look for the biggest SIZE entries.
image historyimage layerslayer sizewhy is image big
Save & Load Images as Tarballs
syntax
docker save -o <file.tar> <image>
docker load -i <file.tar>
example
docker save -o myapp-v1.tar myapp:1.0# Transfer the file, then on the other machine:docker load -i myapp-v1.tar
output
Loaded image: myapp:1.0
Note Useful for air-gapped environments with no registry access. The tarball includes all layers, so it can be large. Consider piping through gzip: docker save myapp:1.0 | gzip > myapp.tar.gz
save imageexport imageload imagetransfer imageoffline imageair-gapped