The Enterprise Section - Docker's Basic Order

Keywords: Docker Ubuntu Nginx network

Start, stop, restart of docker

systemctl start docker        #Start docker service     
service docker start          
systemctl stop docker         #Close docker service 
service docker stop  
systemctl restart  docker     #Restart docker service
service docker restart       
systemctl daemon-reload       #Overload daemon process 
chkconfig docker on           #Boot-up self-starting docker

Container management

docker run -it --name vm1 ubuntu bash   #Create and run a new container (run=create+start) - it represents interactive rows
docker run -d  --name vm1 nginx         #Create and run a new container; - d means entering the background
docker info                             #Display docker system information, including mirrors and number of containers, etc.
docker version                          #View docker container version  
docker search  ...                      #Search for eligible mirrors
docker ps -a                            #View the status of all containers
docker ps                               #View the running container process
docker pull nginx                       #Pull mirror image
docker push                             #Push the mirror to the remote warehouse
docker history nginx                    #View the creation history of the specified image
docker attach vm1                       #Connecting container
docker top vm1                          #View container processes
docker logs vm1                         #View the output of container instructions; - f means real-time viewing
docker inspect vm1                      #View container parameters (get container metadata)
docker stats vm1                        #View container resource utilization
docker diff vm1                         #View Container Modifications
docker start vm1                        #Starting container
docker stop vm1                         #Stop container
docker restart vm1                      #Restart container
docker kill vm1                         #Forced Killing Container
docker pause vm1                        #Pause container
docker unpause vm1                      #Recovery container
docker rm vm1                           #Delete containers; - f means mandatory deletion
docker export vm1 > vm1.tar             #Export container
docker import vm1.tar image             #Import container as mirror image

Image Management

Mirrors are used to create containers and are read-only templates for containers, which can be downloaded from docker hub by default. The mirror image of docker
 Incremental modification, each time a new image is created, an incremental layer is built on the parent image, based on AUFS technology.
docker search                      #Query mirroring
docker pull      				   #Pull mirror image
docker push      			       #Push mirror
docker inspect    				   #View Mirror Details
docker images     				   #List all existing mirrors locally
docker save ubuntu > ubuntu.tar    #Export mirroring
docker load -i ubuntu.tar          #Import mirroring
docker commit                      #Update mirroring
docker rmi        				   #delete mirror
docker build      			       #create mirror

Network management

ip netns add [name]                              #Add a namespace (virtual network space)
ip netns exec [name] ip link set lo up           #Enable a device in namespace
ip link set [dev-name]   netns [name]            #Add a new device to namespace
ip netns exec [name] ip link set [dev-name] up   #Enabling devices
ip netns exec [name] ip addr show [dev-name] permanent scope global                                    #View the parameter information for the specified device in the specified namespace
ip netns exec [name] ip -4 addr add 192.168.1.2/24 brd 192.168.1.255 scope global dev  [dev-name]      #Set up ip for the device specified in namespace
ip netns list                                    #View all network namespace s
ip netns exec [name] ping 192.168.1.3            #ping virtual machine instance

Some Application Examples of Docker Basic Command
How to open docker

How to Import Mirror to docker

docker images view container images

How to create and run a new container (run=create+start) docker run-it -- name vm2 Ubuntu

- name is to set the container name
Uname-r Views Version Information in Containers

docker ps # View the running container process

Docker PS-A # View all container status

docker commit vm2 ubuntu:v1 # create a new image based on the original image
docker history ubuntu: # View the latest creation history of the specified image

docker rm vm2 # delete container; - f means mandatory deletion

docker rmi Delete Mirror

If the container still wants to restart the container docker start vm2

If the container still wants to reload the container (connection container) docker container attach vm2 after starting

If you write Dockerfile and want to read the content of Dockerfile, create the container docker build-t ubuntu: v1.

The detailed description and demonstration of the command can be referred to as follows: https://blog.csdn.net/ymeng9527/article/details/98477602

Posted by ceruleansin on Wed, 09 Oct 2019 06:18:15 -0700