docker info # View local Docker informationdocker search openresty # Search remote image repositorydocker images # View images in the local image repositorydocker ps # View currently running containersdocker pull centos # Pull an image from the remote repository (default tag is 'latest' if not specified)docker container run -p 8000:80 --rm -t -i centos:latest /bin/bash # Map container port 80 to host port 8000; --rm removes the container after termination (useful for temporary debugging); -t allocates a pseudo-terminal and binds it to the container's stdin; -i keeps the container's stdin opendocker container exec -i -t b5d7bad57561 /bin/bash # Enter a running containerdocker rmi $(docker images -f "dangling=true" -q)# Batch remove dangling (unnamed) images
docker save -o centos7.tar centos # Export image to tar filedocker load < centos7.tar # Import image (via standard input, including original metadata such as tags)docker load --input centos7.tar # Load image from tar file (non-standard input method)
docker ps # Default: show currently running containersdocker ps -a # Show all containers, including stopped onesdocker ps -l # Show the most recently created container (including stopped ones)docker export 5a80afa126ba > centos7.5a80afa126ba.tar # Export container snapshotdocker import 5a80afa126ba > centos7.5a80afa126ba.tar # Import container snapshot into image repository
Note: Users can use docker load to import image files into the local image library, or docker import to import container snapshots. The key difference is that container snapshot files discard all historical records and metadata (preserving only the state at the time of the snapshot), while image storage files preserve full history and are larger in size. Additionally, when importing from a container snapshot, you can reassign metadata like tags.
docker image build . # Build image from Dockerfile in current directorydocker image build -t cm-navigation:v0.0.1 . # Build image from Dockerfile in current directory and assign a tag