"Go" Docker common commands

Source: Internet
Author: User

Reprint: http://blog.csdn.net/zhang__jiayu/article/details/42611469 Docker images: List all locally mirrored Docker search <image_id/ Name>:Find ImageDocker pull<IMAGE_ID>: download IMAGE Docker push<image_id>: upload IMAGE Docker RMI<image_id>: Delete IMAGE Container Management
Docker run-i-T <IMAGE_ID>/bin/bash:-i: Standard input to container-T: Assigning a virtual terminal/bin/bash: Execute bash script
-D: Run as Daemon (background)
< Span style= "Background-color:inherit;" >-p: Default matching Docker container's 5000 port number to the host's -p <HOT_PORT>:< CONTAINER_PORT>: Specify port number --name: Specify container name--rm: Delete container docker stop  stop container
 : restart container
Docker ps-lists containers.
-L: Displays the last container started
-
A: Displays the stopped container at the same time, showing only the start status by default

Docker attach <CONTAINER_ID> connect to boot container docker logs <CONTAINER_ID>: output container Log
Docker cp <CONTAINER_ID>:p ath Hostpath: Copy files from container to host directory
<CONTAINER_ID>docker wait <container_id>: Block other calling methods on the container until the container stops and exits

Docker top <container_id>: viewing processes running in a container
<container_id>: Viewing changes in a container
<container_id>: View container details (output as JSON)
-F: Find specific information, such as -' {{. Networksettings.ipaddress}} '

Docker extc-it <CONTAINER> <command&gt: Execute commands in the container and output the results
  • Network management
    Docker run-p: Randomly assigned port number Docker Run-p 5,000:5,000: Bind a specific port number (5000 ports for all network interfaces of the host are bound to 5000 ports of the container) Docker run-p 127.0.0.1:5000:5000: Port number of the specific interface of the binding host Docker run -D-p  127.0 0.1:< Span style= "FONT-FAMILY:SIMSUN; line-height:1.5; " >5000 5000 UDP Training/ . py: Binding UDP port number Docker Port<CONTAINER_ID> 5000: View the container's 5000 port corresponding to the IP and port number of the local machine
    To connect containers using Docker linking:
    Docker run-d-P--name <CONTAINER_NAME>--link <CONTAINER_NAME_TO_LINK>:<ALIAS>
  • -----/WebApp training/webapp python app.  PY        
  • You can also attach a container volume to a host directory or a host file,< the contents of the container directory or file > are replaced with the contents of the < host directory or file >, and the default container has read and write access to the directory
    .
    ----v < host directory >:< container directory > training/webapp python app.  PY         
    You can change the permissions to read-only by specifying RO
     - --- -:< container directory >:r Trainingwebapp python apppy          
    --/--name DB1 training/Data-for postgres     
    First, start a container and add a data volume/dbdata to the container, and then start another container to share the data volume
    -d --volumes-from db1 --name db2 training/postgres
    At this point DB2 uses the DB1 container volume, and when the container DB1 is deleted, the container volume is not deleted, and only if all containers no longer use the container volume are deleted
    Docker rm-v: Deleting container volumes
    in addition to sharing data, the container volume is another function for backing up, recovering, and migrating data
    --volumes-from-v/home/backup://backup/backup.  /dbdata            
    Start a container data volume using the DB1 container's data volume while creating a new data volume pointing to the host directory/home/backup, compressing the/dbdata directory data to/backup/backup.tar
    -v /dbdata --name dbdata2 ubuntu /bin/bash
    --volumes-from-v/home/backup://backup/backup.  Tar           
    Start a container and extract the contents of the Backup.tar to the backup of the container

    Warehouse Management
    Docker Login: Login

"Go" Docker common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.