docker basic common commands (all)

Keywords: Docker CentOS Linux RHEL

  • System and information of docker I use:
[root@VM_0_10_centos ~]# uname -r   #View kernel
[root@VM_0_10_centos ~]# cat /etc/os-release   #View system version and other information
NAME="CentOS Linux"
VERSION="7 (Core)"
ID_LIKE="rhel fedora"
PRETTY_NAME="CentOS Linux 7 (Core)"


Every command has many parameters, but don't remember? It can be solved through – help

[root@VM_0_10_centos ~]# docker pull --help   #Format: the command that docker wants to know parameters -- help

Usage:  docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry

  -a, --all-tags                Download all tagged images in the repository
      --disable-content-trust   Skip image verification (default true)
      --platform string         Set platform if server is multi-platform capable
  -q, --quiet                   Suppress verbose output
  • Mirror related commands
[root@VM_0_10_centos ~]# docker images  #View all mirrors
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
tomcatxc              0.1                 678f9da2b22f        15 minutes ago      652MB
centos                latest              831691599b88        2 days ago          215MB
tomcat                latest              2eb5a120304e        8 days ago          647MB
nginx                 latest              2622e6cca7eb        9 days ago          132MB
portainer/portainer   latest              cd645f5a4769        2 weeks ago         79.1MB

REPOSITORY : Warehouse name
IMAGE ID :image id
CREATED: How long is the image creation time from now
SIZE:Size of the image
docker pull XXX: downloading an image without version is the latest by default
 docker info: View docker information
 docker search image name: used to search all images
 docker rmi image name: used to delete an image 
Docker RMI - f $(docker images -aq): - F is used to follow the parameter, so that all the commands of docker images -aq can be deleted
  • Common commands for containers:
docker run XXX: you can run a container by the image name,
    Common parameters: - d background operation
            -it interactive operation
            -Name container name, it will be named randomly if not written
            -p refers to the host port and the corresponding container port
 docker ps: view running containers
          -aq: add this parameter to find out the containers that have not been deleted
 docker rm container id: delete container
 Docker RM - f $(docker ps -aq): - F is used to follow the parameter, so that all the commands found in docker ps -aq can be deleted
 docker start container id: start a container
 docker restart container id: restart container
 docker stop container id: stop a currently running container
 docker kill container id: force to stop a currently running container
 docker logs -ff --tail 10 container id: view the logs of the current container
 docker top container id: view the process information of container type
 Docker inspection container id: information about the production inspection container
 Docker exit - it container ID / bin / bash: enter the currently running container
 Docker attach container id: enter the container, but enter the executing code
 docker cp container id: file inside container file outside container path
 docker stats: View cpu status
 Docker commit - a = "author" - m = "submission information" container id target image name: version number     

Posted by coverman on Thu, 18 Jun 2020 20:29:05 -0700