
Docker image commands: Manage Docker image downloads, local inventory, builds, tags and cleanup. The guide includes supply-chain and build-context cautions. This guide explains what each command does, its syntax, practical examples, useful options, and common mistakes. Commands are shown for typical installations; flags can vary across operating-system and tool versions.
Before you start
Open a terminal appropriate for the operating system shown in the examples. Check that the required tool is installed and that you are running it with the permissions needed for your task. Replace sample names, paths, hostnames and IDs with values from your own environment.
Syntax at a glance
Square brackets usually indicate optional arguments, while uppercase words such as FILE, HOST and PACKAGE are placeholders that you replace. Keep quotes around paths or text that contains spaces. Commands should be tested on a safe sample before being used in production.
Quick command reference
| Command | What it does | Example | Useful options |
|---|---|---|---|
docker pull | Download an image from a registry | docker pull nginx:stable | Tags are mutable; digest references pin an exact image |
docker images | List locally stored images | docker images --digests | -a includes intermediate images; --digests shows content digests |
docker build | Build an image from a Dockerfile | docker build -t toolxon-demo:1.0 . | -f selects another Dockerfile; --no-cache disables build cache |
docker tag | Add another reference/tag to an image | docker tag toolxon-demo:1.0 registry.example.com/team/toolxon-demo:1.0 | Tags do not duplicate all image layer data locally |
docker image prune | Remove unused images | docker image prune -a | -a includes images not used by any container; -f skips confirmation |
Command syntax and examples explained
1. docker pull
Purpose: Download an image from a registry.
Syntax
docker pull IMAGE[:TAG]Example
docker pull nginx:stableOptions and notes: Tags are mutable; digest references pin an exact image.
Prefer official/trusted images and review image provenance.
2. docker images
Purpose: List locally stored images.
Syntax
docker imagesExample
docker images --digestsOptions and notes: -a includes intermediate images; --digests shows content digests.
Image list size is not equal to total disk reclaimed if layers are shared.
3. docker build
Purpose: Build an image from a Dockerfile.
Syntax
docker build -t NAME:TAG PATHExample
docker build -t toolxon-demo:1.0 .Options and notes: -f selects another Dockerfile; --no-cache disables build cache.
Use .dockerignore to keep secrets and unnecessary files out of build context.
4. docker tag
Purpose: Add another reference/tag to an image.
Syntax
docker tag SOURCE TARGETExample
docker tag toolxon-demo:1.0 registry.example.com/team/toolxon-demo:1.0Options and notes: Tags do not duplicate all image layer data locally.
Ensure the target registry/repository is correct before pushing.
5. docker image prune
Purpose: Remove unused images.
Syntax
docker image pruneExample
docker image prune -aOptions and notes: -a includes images not used by any container; -f skips confirmation.
Cleanup removes cached images and can force later re-downloads; review scope first.
Common mistakes and troubleshooting
- Command not found: confirm the tool is installed and available on your PATH; open a new terminal after changing PATH.
- Permission denied: verify the current account, file permissions and target path. Use administrator/root privileges only when genuinely required.
- Unexpected output: check the command version, quoting, current directory and exact arguments. Consult the local help or manual for options supported by your build.
- Destructive operations: preview the target and keep a backup before deleting data, rewriting history, flashing a partition or changing system configuration.
Safety tips
Review every command before running it, especially commands that delete files, change permissions, flash firmware, alter a database or expose a network service. For network scanning and remote administration, work only on devices and systems you own or are authorized to test. Keep credentials, private keys, access tokens and log files private.
Frequently asked questions
Do these commands work on every system?
Not always. Some commands are specific to Windows, Linux, Android, a particular package manager or an installed tool version. Use the syntax shown for your platform and check local help when a flag is unavailable.
Can I copy and run every example exactly?
Use the examples as templates. Replace placeholders such as filenames, package IDs, hostnames and paths with your own values, and verify the effect before executing a command that changes data or system state.
Conclusion
Use this reference as a starting point, then confirm flags in the tool’s official help or manual for your installed version. A clear understanding of syntax, options and side effects makes command-line work more reliable.