• Creating a Boot Imagedocker runThis command is the most commonly used command. It mainly uses the following options: ① -d: indicates background operation. ② -P (in uppercase) : indicates random port mapping.The host port is preceded by the container port, such asdocker run nginx -p 8080:80, map port 80 of the container to port 8080 of the host, and then uselocalhost:8080The nginx welcome page in the nginx container is displayed.The host directory is preceded by the container directory, such asdocker run -d -p 80:80 -v /dockerData/nginx/conf/nginx.conf:/etc/nginx/nginx.conf nginxMounted to the host/dockerData/nginx/conf/nginx.confFile so that the host can pairnginxIf the host directory does not exist, it will be created automatically. ⑤–rm: Stop the container and delete it directlydocker run -d -p 80:80 --rm nginx⑥–name: give the container a name, otherwise a long list of custom names will appeardocker run -name niginx -d -p 80:80 - nginx
  • List the containerdocker psThis command lists the currently running containers, using-aList all containers after the parameter (including stopped ones)

  • Stop the containerdocker stop docker stop 5d034c6ea010This is followed by the container ID, or you can use the container name
  • Start the stopped containerdocker start docker runCreate a new container and start it,docker startIs a container for starting and stopping, such asdocker start 5d034c6ea010
  • Restart the containerdocker restartThis command is executed firstdocker stop, and then executedocker start, such asdocker restart 5d034c6ea010
  • Into the containerDocker exec -it Container ID /bin/bashdocker exec -it 5d034c6ea010 /bin/bash, which is equivalent to accessing the operating system of the container itself
  • Remove the containerdocker rmdocker rm 5d034c6ea010The container ID is followed by the need to stop the container before deleting it
  • Data copiesdocker cpThis command is used to copy data between a container and a host, for exampledocker cp 5d034c6ea010: /etc/nginx/nginx.conf /dockerData/nginx/conf/nginx.confCopy the container directory file to the specified location on the host. The container ID can be replaced by the container name.