Common Commands
Command |
Description |
|---|---|
docker pull ubuntu:17.10 |
Pull the ubuntu:17.10 image. |
docker port CONTAINER |
Check current port mapping configuration. |
docker inspect NAME|ID |
Get detailed information about Docker objects (such as containers, images, volumes, and networks). |
docker info |
Display detailed Docker system information including version, storage driver, number of images/containers, and other important configuration details. |
docker ps |
List running containers. Add the -a option to view all containers. |
docker images |
List local Docker images. |
docker commit CONTAINER REPOSITORY[:TAG] |
Save the modified image as a new image. |
docker export CONTAINER > container.tar |
Export the file system of a container as a TAR archive. |
docker import image.tar |
Create a Docker image from a TAR archive or URL snapshot. |
docker save -o image.tar IMAGE |
Save one or more Docker images to a TAR archive for distribution or backup. |
docker load -i image.tar |
Load Docker images from a TAR archive created by docker save. |
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] |
Create an alias (tag) for a local image. |
docker cp SRC_PATH CONTAINER:DEST_PATH docker cp CONTAINER:SRC_PATH DEST_PATH |
Copy files or directories between the Docker container and host machine. |
docker run -it -d -p 5900:5900 -p 15555-15577:15555-15577 --name mesa0 --privileged -v /root/share:/root/share ubuntu:17.10 /bin/bash |
Start a container (example). -it: runs the container interactively within a pseudo terminal. -d: runs the container in the background and returns the container ID. -p: maps container_port to host_port. --name: assigns a name to the container. -v: mounts host_dir to container_dir. |