An image contains the application binaries, application dependencies, metadata about the image and how to run the image.
Official images on Docker Hub just have an
<image-name> unlike others which follow the format
# Pulls the latest version docker pull <image-name>
docker pull <image-name>:<image-version>
docker pull <image-name>:<image-version>-<dist>
To upload changed layers to an image registry:
docker image push <image-name>
NOTE: To perform push, we need to login with
docker image ls
Image layers present a series of file system changes as an actual file system.
docker history <image-name>:image-version>
Each layer in the image has a unique SHA, so that, if another image has a same version of a layer and the layer exists in the cache, that layer will be re-used, i.e., the rest of the layers in the image are run on top of the cached layer.
Same layers are not stored more than once on the host system.
Container layer is a read and write layer created on top of the image layer.
When a file on the image is changed as part of the container, the difference in the file is copied over to the container (copy on write) without making any changes in the history of the container.
# Get JSON metadata about the image docker inspect <image-name>:<image-version>
docker image tag <source-image>:<source-tag> <target-image>:<target-tag>
Tags will default to
latest unless specified.
latestis just a default tag that should be assigned to the newest stable version.
docker image build -t <image-name> .
. will search for the default Dockerfile.
-tis a shorthand for
Clean up all dangling images:
docker image prune
Clean up everything:
docker system prune
Remove all unused images:
docker image prune -a
View space usage:
docker system df