Pulling images from registries
Thecontainer image pull command downloads an image from a registry to your local machine.
Basic usage
Platform-specific pulls
You can specify the platform when pulling multi-platform images:The
--platform option takes precedence over --arch and --os flags. Use the format os/arch[/variant].Registry authentication
For private registries, authenticate first:Building images
Thecontainer build command creates OCI images from a Dockerfile or Containerfile.
Basic build
Dockerfile in the current directory and tags it as my-app:latest.
Using a custom Dockerfile
When no
-f/--file is specified, the build command will look for Dockerfile first, then fall back to Containerfile if Dockerfile is not found.Build arguments
Pass build-time variables to your Dockerfile:Multi-stage builds
Build a specific stage from a multi-stage Dockerfile:Multiple tags
You can apply multiple tags to an image during build:Build options
- Resource control
- Cache control
- Output control
Default builder resources are 2 CPUs and 2048MB memory. Increase these for resource-intensive builds.
Building multiplatform images
You can create an image that supports both Apple silicon Macs and x86-64 servers:Testing platform variants
Try running the commanduname -a with different architecture variants:
When you run the command with the
amd64 architecture, the x86-64 version runs under Rosetta translation on Apple Silicon Macs.Pushing images to registries
Thecontainer image push command uploads an image to a registry.
Basic push
Pushing multiplatform images
The command to push your multiplatform image to a registry is no different than that for a single-platform image:By default
container is configured to use Docker Hub. You can change the default registry by running:Tagging images
Thecontainer image tag command creates a new tag for an existing image without duplicating the image data.
Basic tagging
Multiple tags
The original image reference remains unchanged. Tagging creates an alias to the same image data.
Listing images
Thecontainer image list (or container image ls) command shows your local images.
Basic listing
Output formats
- Table format
- Verbose
- JSON format
- Quiet mode
Inspecting images
Thecontainer image inspect command displays detailed information in JSON format:
Saving and loading images
Saving images to tar archives
Export images for offline transport:Loading images from tar archives
Import images from a tar archive:The tar file must be created by
container image save or be in OCI tar format.Deleting images
Thecontainer image delete (or container image rm) command removes one or more images.
Delete specific images
Delete multiple images
Delete all images
Force deletion
--force flag ignores errors for images that are not found.
Pruning images
Thecontainer image prune command removes unused images to reclaim disk space.
Remove dangling images
Remove all unused images
Pruning helps reclaim disk space from unused layers and old images.
Managing the builder
When you first runcontainer build, container starts a builder, which is a utility container that builds images from your Dockerfiles.
Configuring builder resources
For resource-intensive builds, increase the memory and CPU limits for the builder VM:By default, the builder VM receives 2 GiBytes of RAM and 2 CPUs.
Restarting the builder with new limits
If your builder is already running and you need to modify the limits:Checking builder status
Stopping the builder
Deleting the builder
--force to delete even if running: