LinuxCommandLibrary

docker-image

Manage Docker images (build, tag, remove)

TLDR

List local Docker images

$ docker image ls
copy

Delete unused local Docker images
$ docker image prune
copy

Delete all unused images (not just those without a tag)
$ docker image prune [[-a|--all]]
copy

Show the history of a local Docker image
$ docker image history [image]
copy

View documentation for docker image rm
$ tldr docker rmi
copy

SYNOPSIS

docker image [OPTIONS] COMMAND

PARAMETERS

build
    Build an image from a Dockerfile.

history
    Show the history of an image.

import
    Import the contents from a tarball to create a filesystem image.

inspect
    Display detailed information on one or more images.

load
    Load an image from a tar archive or STDIN.

ls
    List images.

prune
    Remove unused images.

pull
    Pull an image or a repository from a registry.

push
    Push an image or a repository to a registry.

rm
    Remove one or more images.

save
    Save one or more images to a tar archive (streamed to STDOUT by default).

tag
    Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

DESCRIPTION

The `docker image` command family in Linux provides a suite of tools for managing Docker images directly from the command line. These commands enable users to list, inspect, remove, tag, prune, and import/export Docker images. Image management is a cornerstone of working with Docker containers, as images are the read-only templates used to create and run containers. Understanding how to effectively use the `docker image` commands is critical for building, deploying, and maintaining containerized applications.

These commands provide a vital interface between the Docker daemon and the user, allowing for programmatic control over image storage, access, and distribution. It allows you to manipulate images without needing docker files and is suitable for fast image manipulations.
From listing available images to cleaning up unused ones, these commands facilitate efficient workflow and ensure a clean and secure container environment.

IMAGE LAYERS

Docker images are composed of read-only layers. Each layer represents a set of file system differences. When a container is created from an image, a thin writable layer is added on top of the existing layers. This layered architecture facilitates efficient storage and image reuse.

IMAGE NAMING

Docker images are identified by a name and tag. The name identifies the image, and the tag specifies a particular version or variant. The default tag is `latest`. For example `ubuntu:20.04`.

SEE ALSO

Copied to clipboard