Skip to main content

Image Commands

An image is the read-only template of a container. This page covers the common commands for pulling, building, inspecting, and cleaning up images.

Pull an image​

Download an image from a registry (Docker Hub by default) to your local machine:

Linux
docker pull ubuntu:22.04

Without a tag, latest is pulled by default. Always pin a concrete tag for reproducibility:

Linux
docker pull ros:humble

💡 If the pull fails with i/o timeout, configure a registry mirror from the install guide first.

List local images​

List downloaded images with repository, tag, image ID, and size:

Linux
docker images

Show only image IDs (handy for scripted batch operations):

Linux
docker images -q

Build an image​

Build from a Dockerfile. -t sets name:tag; the trailing . is the build context (current directory):

Linux
docker build -t my-ros-app:1.0 .

For multi-stage builds or cache control, add --no-cache:

Linux
docker build --no-cache -t my-ros-app:1.0 .

Tag an image​

To rename or push to a private registry, add a new tag (no data copy, just a new reference):

Linux
docker tag my-ros-app:1.0 registry.example.com/my-ros-app:1.0

Save and load​

To move images across offline hosts, save to a tarball then load it:

Linux
docker save -o my-ros-app.tar my-ros-app:1.0
docker load -i my-ros-app.tar

Remove an image​

Remove by image ID or tag; -f force-removes an image still referenced by a container (not recommended — remove the container first):

Linux
docker rmi my-ros-app:1.0

Clean up dangling images (tag <none>) not used by any container:

Linux
docker image prune
tip

Free disk space in one command

Remove all unused images, containers, networks, and build cache (use with care):

Linux
docker system prune -a
Join Us