Privacy Policy
© 2026 linux101.dev

Docker Image Cheatsheet

A Docker image is a read-only, static template that contains the instructions for creating a Docker container. Here are the most common commands for managing images.

Basic Image Operations

These commands are for managing images on your local machine.

CommandDescription
docker build -t [NAME]:[TAG] .Builds a new image from a Dockerfile in the current directory, tagging it with a name and version. The dot at the end specifies the build context, which is the directory containing the Dockerfile and any other files needed for the build.
docker build -t [NAME]:[TAG] -f path/to/Dockerfile .Builds a new image from a specified Dockerfile, tagging it with a name and version. Relative paths in the Dockerfile will be resolved relative to the build context (the directory specified by .).
docker images
docker image ls
Lists all images stored on your local machine. You can also use docker image ls.
docker tag [SOURCE_IMAGE]:[TAG] [TARGET_IMAGE]:[TAG]Creates a new tag (alias) for an existing image. This is useful for versioning or preparing an image to be pushed to a registry.
docker rmi [IMAGE_ID or IMAGE_NAME]
docker image rm [IMAGE_ID or IMAGE_NAME]
Removes an image from your local machine. Use the -f flag to force removal of an image used by a stopped container.

Sharing Images

These commands are for sharing images with others, either through a registry or by manual transfer.

CommandDescription
docker push [IMAGE]:[TAG]Uploads a tagged image to a Docker registry (e.g., Docker Hub). You must first log in using docker login.
docker pull [IMAGE]:[TAG]Downloads an image from a Docker registry.
docker save -o [FILE].tar [IMAGE]:[TAG]Saves one or more images into a .tar archive. Useful for sharing images without a registry.
docker load -i [FILE].tarLoads a .tar archive from a file into the local Docker image cache.
Desktop Ad Placeholder