Command description
Docker Pull
Format:
Docke pull [OPTIONS] Name[:tag]
Role: Download the image named name
Example:
sudo Docker pull dl.dockerpool.com:5000/ubuntu:12.04
Description
An Ubuntu image with a tag value of 12.04 is downloaded from dl.dockerpool.com:5000, and the image is downloaded from registry.hub.docker.com by default when dl.dockerpool.com:5000 is omitted.
Docker Commit
Format:
Docker commit –m "description information" –a "user Information" Create a mirrored container ID warehouse Name: TAG
Role:
After committing the changed container, the ID of the mirror is returned after successful submission
Example:Docker Commit –m "Update Mirror" –a "Chenx" D2A0ECFFE6FA Ouruser/sinatra:v2
Docker Build
Format:sudo Docker Build –t= "Mirror name: TAG" The path where the Dockerfile
Role: Creating Mirrors
Example:
sudo Docker build -t= "Aicep:v1 " .
Docker Import
Features: Import mirrors from Local system to Docker
Example:
sudo Cat Ubuntu-14.04-x86_64-minimal.tar.gz|docker Import – unbuntu-14.04
Docker Run
Function: Run container
Parameter description:
--rm=true indicates that the staging container is started and will be deleted after the run finishes
Format:
sudo Run –t –i image name: TAG process name to execute (container name)
Example:
sudo Docker Run –t –i Ouruser/sinatra:v2 /bin/bash
The difference between-p and-p
Container port (6000) mapped to the host machine (5000)
sudo docker run–d–p 127.0.0.1:5000:6000 Aicep:v1/bin/bash
Container randomly allocated ports mapped to randomly allocated ports in the host machine
sudo docker run–d–p Aicep:v1/bin/bash
When Docker has an automated requirement, you can output Containerid to the specified file (pidfile):--cidfile= ""
Docker containers are not privileged, such as the inability to start a container in a container. This is because the container does not have access to any other devices by default. However, with "privileged", the container has access to any other device.
Remove container when exiting
Docker Run--rm=true–t–i Ouruser/sinatra:v2/bin/bash
Port mappings
Docker run–i–t–p
File sharing
Create and start the container test by mirroring Test:v1, and share the local directory/docker/volume with the directory/var/tmp in the container.
Docker run–v/docker/volume:/var/tmp--name Test–iv Test:v1/bin/bash
Docker Push
Function: Upload the image you created to the repository to share.
Example:
sudo Docker Push Ouruser/sinatra
Docker PS
Docker PS # #查看正在运行的Container
Docker Ps–a # #列出所有的Container
Docker Ps–l # #列出最近一次运行的Container
Docker RMI
function: Remove the mirror, note that the container that depends on the mirror must be removed before removing the mirror
Format: Docker RMI <image id>
# #删除id为 <none> Mirror
Docker RMI $ (Docker images | grep "^<none>" |awk "{print $}")
# #删除全部的image
Docker RMI $ (Docker images-q)
Docker RM
Function: Delete container
Docker RM & (Docker ps–a-q) # #删除所有容器
Docker stop
Function: Stop container
Docker stop $ (Docker ps–a-q) # # Stop all containers
Docker Inspect
Features: View Image/container bottom-specific details
Find volume where the host is stored
Docker inspect–f {{. Volumes}} continer-test
View Container IP
Docker Inspect--format= ' {{. Networksettings.ipaddress}} ' containername/id
Gets the process ID of a container
Docker Inspect–format "{{. State.pid}} "<continer-id>
Docker start
Function: Start container
Format: Docker start name/id # #容器名或者容器ID,
Docker start–i name/id # #启动一个container并进入交互模式.
Docker Kill
Function: Kill container
Format: Docker kill Name/id # #容器名或者容器ID
Docker copy
Function: Copy files from container to local
Format: Docker copy (name or ID):/path local path in container
Docker logs
Function: Take logs from the container
Format: Docker logs Id/name
Docker diff
Function: Lists the files or directories changed by the container, the list shows three events, a added, b deleted, C changed
Format: Docker diff Id/name
Docker Restart
Function: Restart container
Format: Docker Restart Id/name
Docker Attach
Function: Attach a running container (Docker exec is recommended), reconnect the container session, and the container will shut down when it disconnects.
Format: Docker attach <container>
Docker Port
Function: View which port on the local map to the specified port of container, Docker PS can also view
Format: Docker Port <container> <container port>
Docker Exoport
Function: Export container
Format: Docker export <containerID> > Local Path
Example: Docker export Jdkimage >/docker/jdkcontainer.tar
Docker Save
Function: Export image
Format: Docker save–o Local Path <imageID/name>
or Docker save <imageID/name> > Local Path
Example: Docker save-o/docker/jimages.tar QCDATAINC/CENTOS-JDK
Docker exec
Introduced in Docker3, function: Enter into the specified container to interact.
Format: Docker exec–it <conttainerID/name> commands
Docker Create
Function: Create container (does not start)
Format: Docker create [OPTIONS] IMAGE [COMMAND] [ARG ...]
Example
Docker create-it--name=service Chenx/service/bin/bash
Docker Series (iii) common commands