Docker notes
Docker installation
CentOS 7 yum install docker
two。 Common command operation commands describe running docker run-- name container-name-d image-name:tag such as: docker run-- name myredis-d redis--name: custom container name-d: indicates that the background is running image-name: specify the name of the running image tag: list of versions of the image docker ps (view the running container); add-a You can view all containers stop docker stop container-name/container-id to stop the current operation of the specified container start docker start container-name/container-id start container delete docker rm container-id delete specified container port mapping-p 6379docker rm container-id 6379 such as: docker run-- name myredis-d-p 6379docker rm container-id docker rm container-id 6379: host port is mapped to the port inside the container docker logs container-name/container-id-tomcat installation tomcat runs
Docker run-it-- rm-p 8888 purl 8080-v $PWD/webapps:/usr/local/tomcat/webapps tomcat:latest
-it # is the abbreviation of-I and-t, which means to run the container in an interactive way, plus-d means to run in the background. Here, I use-it for screenshot output, or-d, and then use the "docker logs container name" command to output the log.
-- rm # automatically deletes a container when it is stopped
-p 8888 8080 # 80 is the port set for the tomcat in the container, which means that 8080 is mapped to host port 8888. If only-p 8080 is written, the container will randomly take the larger port number in the value 32768mm 61000 to map to port 8080.
-v # Map the usr/local/tomcat/webapps directory in tomcat to the webapps directory of the current host directory, and then update the jar package and throw it directly into the mapped host directory.
Tomcat:latest # Image name: tag tag
Backup and migration
The container is saved as a mirror
Docker commit pyg_nginx mynginx
Pyg_nginx is the container name
Mynginx is the new image name