Memo for common commands in docker cli command line tool (to be continued)

sudo docker images tomcat* //View the list of mirror information starting with tomcat

sudo docker pull php //Download the official image layer file whose coordinate name is php

sudo docker rmi php:5.6-fpm //Delete the image whose coordinate name is php:5.6-fpm

sudo docker inspect nginx:1.10 //View the detailed description of the image file named nginx:1.10

docker search php* //Search the image layer file information starting with php in the official mirror warehouse

sudo docker images //View the list of mirror names in the local mirror library

sudo docker save Image name: tag name>xxxx.tar //Save and export a local image to the xxxx.tar file

sudo docker save -o ubuntu.tar ubuntu:latest //This example is to export a ubuntu:latest image to a file named ubuntu.tar

sudo docker save -o images.tar ubuntu:latest centos:latest //Export multiple image files to an archive file named (custom) images.tar

sudo docker load -i ubuntu.tar //Reimport the exported image archive data file ubuntu.tar into the local mirror warehouse using the docker load command

sudo docker load <ubuntu.tar // etc. sudo docker load -i ubuntu.tar

sudo docker create debian:jessie //Use the docker container engine to create a container instance based on the debian:jessie image

sudo docker run debian:jessie //Run the container instance loaded with the debian:jessie image

sudo docker start web //Start the docker container, where web is the container name (you can specify a container instance name when creating the container)

sudo docker start 8a136 //You can only pass in the first part of the container id, as long as you can judge the uniqueness of the container id in the docker engine, you can see the return result after startup: container name or container id

sudo docker start nginx phpfpm mysql //An example of starting multiple containers with multiple container identifier names, separated by spaces between multiple containers, pay attention to the order of dependency between containers to start is the best

sudo docker stop phpfptm // Stop the container In this example, phpfptm is a container name

sudo docker kill web // Forcibly kill the container. In this example, web is a custom container name. Principle: The docker kill command will directly send a sigkill signal to force the end of the main process in the container

sudo docker pause web // Pause the operation of the container instance named web

sudo docker unpause web //Resume the suspended container instance named web is running again

sudo docker ps -l //View the running container instance and its main process

sudo docker restart web //Restart the container is equivalent to sudo docker stop web + sudo docker start web  

sudo docker rm web //Delete the container instance named web

sudo docker top web //View the list of processes running in the container instance web

sudo docker inspect web //View the detailed information of the container instance named web in the docker engine

sudo docker logs web //View the running log output information of the container named web

sudo docker logs -f --tail 50 web //Continue to display the content of the last 50 lines of the running log. Represents the tail 50 lines

sudo docker logs -f --tail 0 web //Continuously view the running log content of the container web from the current time onwards

sudo docker logs --since 2018-08-09T05:56:29 web //Display running log information since a given time, the container name in this example is web

sudo docker attach web // Enter into the container named web, and connect the current command terminal terminal program to the standard input and standard output streams of the main process in the container to complete the current display terminal program terminal and this example The interaction of the main process program in the web container is equivalent to the container entering the foreground interactive operation mode . It should be noted that the docker attach command will bind the current terminal to the main program running in the container instance, so we can continue to receive The content of the process output. At the same time, when we use ctrl + c and other key combinations to send a stop signal to the main program in the container instance, although the command will be the main program in the container, it is only due to the container and its internal There is a life cycle two-way binding mechanism between the main program of the, so when the main program is terminated, the container will also be terminated, which means that after we connect to the container with the docker attach command, the operations performed will interact with the direct use The effect of starting the container in the form of operation is the same, all operations are carried out for the application in the container, including the stop signal of the program is also sent to the main program in the container through the terminal

___________________________________

sudo docker exec web ps //Execute the ps program command on the linux container container instance named web (execute a brand new ps instruction in the container named web to start a new ps process)

sudo docker exec web tail -f /var/log/nginx/access.log  //The green part is the content of the Linux command to be executed in the container named web. By default, sudo docker exec will enter the command terminal The terminal program is connected to the output stream of the program or instruction executed by docker exec. If all the programs executed by docker exec have been executed, we will see this example in the current terminal program (displayed in the terminal) Tail -f /val/log/nginx/access.log command execution output result

sudo docker exec -it web tail -f /val/lgo/nginx/access.log //Assign interactive terminal interactive pseudo terminal to the tail command, which is used to display the content of the tail command execution

___________________

sudo docker commit -m "messagesxxx" absdfsdfsdf7736 ymd/crontab:latest

The mirror image of ymd/crontab:latest, where -m means "message" in this example, and absdfsdfsdf7736  is the container instance id  in this example

ymd/ is the namespace of the image cromtab is the name of the custom image: latest is the name of the custom label of the image, the generated image ymd/contab:latest will be submitted to the local image warehouse

——————————————————————————

sudo docker export container instance id >xxx.tar //Regardless of whether the container is running or not, you can use the docker export command to save the container to a compressed file. The compressed file in this example is xxx.tar

This instruction is equivalent to

sudo docker export -o xxx.tar container instance id 

________________________________________________

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/zy103118/article/details/109778443