Current location - Health Preservation Learning Network - Slimming men and women - Complete works of Docker commands
Complete works of Docker commands
First, let's understand the explanations of three nouns:

1, image

Docker image is a read-only template.

For example, an image can contain a complete operating system environment, in which only Apache or other applications required by users are installed. Mirrors can be used to create Docker containers, and a mirror can create many containers.

2. Warehouse (repository)

A repository is a place where image files are stored centrally.

Step 3: containers

Docker uses containers to run applications. A container is a running instance created from an image.

Two: The commonly used command sets are as follows:

Container Life Cycle Management-Wharf

[Run | Start | Stop | Restart | Terminate | rm | Pause | Unpause | Create]

Container operation and maintenance-dockers

[PS | Execute | Check | Top | Attach | Event | Log | Wait | Export | Import | Port]

Container rootfs command -docker

[Submit | cp | Variance]

Local image management -docker

[Image | rmi | Label | Build | History | Save]

Mirror warehouse-wharf

[Login | Pull | Push | Search]

Other commands -docker

[Info | Version]

Detailed command instructions are as follows:

Docker run-d-namealias-nameimagename//starts the container in the background.

Docker start name /ID // start container

Stop name /ID // Stop container.

Docker restart name /ID // Restart the container.

Docker kill -s KILL Name/ID // kills a running container.

Docker rm /rm -f name /ID // Delete container.

Stop Stop Name /ID // Stop Container.

Docker unshelves the name /ID // recovery container.

Docker create-namecontainer _ nameimagename//only creates the container and does not start it.

Docker ps/docker ps -a // View the running container.

Docker exec-itcontainer _ id/bin/bash//Make a running container and open a new terminal.

Docker attach CONTAINER_ID // Make a running container without opening a new terminal.

Docker inspect CONTAINER_Name // View information about containers.

Docker top CONTAINER_Name // View the processes in the container.

Related events after docker events-f "image" = "imagename"-since = "1467302400"//timestamp = 2065438+July 16.

Docker logs CONTAINER_Name // View the log output of the container.

Docker wait CONTAINER_Name // blocks the operation until the container stops, and then prints out its exit code.

Dockerexport-o test.tar container _ id//Pack the container and save it locally. File type is tar.

Carter test.tar | docker import-image _ name: tag//Import the file saved above into the mirror library.

Docker port CONTAINER_ID // View the port mapping of the container.

Submit creates a new image from the container.

docker commit-a " Tony test "-m " my MySQL " CONTAINER _ ID mymysql:v 1

Docker picture mymysql:v 1

When cp is used, it will exchange data between multiple hosts and containers.

docker CP/Rui qi/content CONTAINER _ ID:/Rui qi/

Diff is used to check the change of file structure in the container.

Terminal differential container identification

Docker images /docker images -a // View local mirrors, -a means all mirrors.

Docker rmi -f image_name // Delete the mirror.

Docker tag MySQL:v 5.6 MySQL:v 5.7// Make an alias copy of the image.

docker build-t run OOB/Ubuntu:v 1。 //Create a mirror image.

Docker history image_name // View the current historical information of this mirror.

Docker save-o TestFlask.tar testflash: v3//Saves the current image to a local tar file.

Docker login//login mirror warehouse.

Docker pull // Extract images from the image library.

Docker push // Push the local image file to the image repository.

Docker searches//retrieves mirrored content.

Thirdly, using dockerfile to make tomcat running image;

[root @ localhost common]# more docker file . Tomcat

From daocloud.io/centos:7.

Copy JDK-8u144-Linux-x64.rpm/opt/JDK-8u144-Linux-x64.rpm.

Run ["rpm ","-ivh ","/opt/JDK-8u144-Linux-x64.rpm "].

Copy security/usr/Java/JDK1.8.0 _144/JRE/security.

Copy certificate /etc/PKI/TLS/ certificate

Copy tomcat /opt/tomcat

Run ["ln ","-s ","/opt/tomcat ","/usr/local/tomcat"].