Basic commands for Docker

  1. Basic commands to
    docker versionview [docker] version View  docker
    docker infodetails View docker
    docker --helpcommands 2. Image
    commands to
    docker imagesview
    docker
    images There can be multiple TAGs, representing different versions of the repository source, we use REPOSITORY:TAG to define different images. If you do not specify a version tag of an image, such as using only tomcat, docker will use the tomcat:latest image by default to list all local images, only display the image ID , display the summary information of the image, display the complete image information , and find the tomcat image on Docker Hub STARS : Find the tomcat image with a following degree greater than 30 on Docker Hub and download the tomcat image from Docker Hub. Equivalent to: Commit the container to make it a new image. For example: delete the hello-world image from Docker Force delete the hello-world image from Docker Force delete the hello-world image and nginx image from Docker Delete all images by querying the image ID

docker images -a
docker images -p
docker images --digests
docker images --no-trunc
docker search tomcat

docker search -s 30 tomcat
docker pull tomcat pull tomcat:latest
docker rmi hello-world
docker rmi -f hello-world
docker rmi -f hello-world nginx
docker rmi -f $(docker images -p) images -p
Third, the container command.
docker run [OPTIONS] IMAGECreate and start a container based on the image. IMAGE is the image ID or image name
OPTIONS Description:
 –name=“new container name”: specify a name for the container
 -d: run the container in the background and return the container ID, that is, start the daemon container
 -i: run in interactive mode Container, usually used with -t
 -t: reassign a pseudo input terminal for the container, usually used with -i
 -P: random port mapping
 -p: specify port mapping, there are four formats:
  ip:hostPort:containerPort
  ip::containerPort
  hostPort:containerPort
  containerPort
docker pslist all currently running containers
docker ps -alist all containers
docker ps -llist recently created containers
docker ps -n 3list the 3 most recently created containers
docker ps -qonly show container IDs
docker ps --no-truncshow all currently running containers complete information
exitexit and Stop the container
Ctrl+p+q, only exit the container, do not stop the container,
docker rm -f $(docker ps -a -q)delete multiple containers  , and
.docker logs -f -t --since=”2018-09-10” --tail=10 f9e29e8455a5

–since : This parameter specifies the start date of the output log, that is, only the logs after the specified date are output
 –tail=10 : View the last 10 logs
For example:docker cp f9e29e8455a5:/tmp/yum.log /root

Leave a Comment

Your email address will not be published. Required fields are marked *