Docker Command Summary

A, Docker base command

[root @ localhost ~] # docker search dhcp # DHCP to search mirror as a key
[root @ localhost ~] # docker pull docker.io/networkboot/dhcpd # check out the download of a mirror
[root @ localhost ~] # docker images # queries downloaded image
[root @ localhost ~] # docker tag docker.io/networkboot/dhcpd dchp: dhcp # change the new name and label
[root @ localhost ~] # docker rmi docker.io/networkboot/dhcpd # Remove mirror
[root @ localhost ~] # docker save -o dhcptest dchp: dhcp # export to local mirror
[root @ localhost ~] # docker load --input dhcp # import image
# or
[root @ localhost ~] # docker load <dhcp # introducing mirror
[root @ docker ~] # docker save> dhcp busybox: latest # image derived busybox
[the root @ localhost ~] # # Docker Push docker.io/ljztest/dhcp image uploaded
[root @ localhost ~] # docker create -itd dchp: dhcp / bin / bash # Create a container, and specify the pseudo terminal
# options are explained below:

  • -i: Interactive
  • -t: assign a terminal
  • -d: background
    [root @ docker ~] # docker run -itd --name test2 --restart = always httpd # holding container is switched from the enabled state
    # action is performed when the "systemctl restart docker", the container is also will restart;
    # if left --restart, then once the implementation of "systemctl restart docker", the vessel will stop.
    [root @ localhost ~] # ID No. docker ps -a # container isolated
    [root @ localhost ~] # docker exec -it 2304f92a8158 / bin / bash # enters a container
    [root @ docker ~] # docker attach test1 # is enter a container
    # If attach into the container, then use the exit to exit this container will be closed.
    # Use ctrl + p ctrl + q to exit the container and does not close the container, the container will remain running.
    [root @ docker ~] # docker ps -a -q | xargs docker start # Open All containers
    [root @ docker ~] # docker ps -a -q | xargs docker stop # close all containers
    [root @ docker ~] # docker View logs test1 # container logs, you can add "-f" option in the back, dynamic output
    [root @ docker ~] # docker ps -a -q | xargs docker rm -f # delete all containers, the power of no less than rm - rf / *
    [root @ localhost ~] # docker ps -a -q | xargs docker start # start all containers
    [root @ localhost ~] # docker rm 2304f92a8158 # delete container
    [root @ docker ~] # docker run -it --name containerB - c 512 centos
    right containerB # create a named container, which is provided to the CPU weight 512
    [Docker the root @ ~] RUN # Docker Expediting iT --name testA --device-Write-bps / dev / SDA: 30MB CentOS
    # restrictions the size of the disk per second can be written as 30MB
    # which can also have the following options:
    # - device-the read-bps: set reading device bps
    # - device-the write-bps: set written to the device bps
    # - -device-read-iops: reading apparatus provided iops
    # - device-write-iops: iops writing device is provided.
    [root @ docker lv] # docker history test04: latest # If you are using Dockerfile mirrored, can use this command to view the image have done what
    [root @ docker ~] # docker logs web01 # View container logs, you can add " -f "option, dynamic refresh.
    [root @ docker ~] # docker commit web01 mytest: v1.0 # container fabricated as a mirror
    [root @ docker ~] # docker cp /a.txt web01: / usr # copy files native to the vessel
    [root @ docker ~] # docker cp web01: /usr/a.txt / usr # in the container copy the files to the machine

Second, related docker network management commands:

[root @ docker ~] # docker network ls # View docker network
[root @ docker ~] # brctl show # to view a virtual private network
[root @ docker ~] # docker exec web ip a # to view a given container network information
[root @ docker ~] # docker network create -d bridge my_net # create a docker's network, -d: Specifies the drive type
[root @ docker ~] # docker network create -d bridge --subnet 172.22.0.0/24 my_net2 # when creating a network, specify the network segment
[root @ docker ~] # docker network inspect my_net2 # to view details of the network
[root @ docker ~] # docker inspect web05 # View container details
[root @ docker ~] # docker inspect web05 # to view details of the container
when [root @ docker ~] # docker run -tid --name web07 --network my_net2 --ip 172.22.0.8 busybox # launch container, together with the specified IP address.
[root @ docker ~] # docker exec web03 ping 172.17.0.3 # does not enter the virtual machine to ping.
[root @ docker ~] # iptables -save # iptables rules View
[Docker the root @ ~] # Docker Network Connect my_net web001
# my_net the web001 connected to the network, after performing an extra card will web001 and my_net network having IP address.

Three, docker Swarm cluster of commonly used commands

[root @ docker01 ~] # information docker node ls # View cluster (can only be viewed on the manager role of the host)
[root @ docker01 ~] # Docker the Swarm the Join-token worker # If the latter need to join the worker side, you can do this command to view the token (ie command to be executed when added)
[root @ docker01 ~] # Docker the Join the Swarm # above-token manager, manager to join the end, you can execute this command to view the token.
[root @ docker01 ~] # docker service scale web05 = dynamic expansion 6 # container and volume reduction
[root @ docker01 ~] # docker service ps web01 # container runs view created which node
[root @ docker01 ~] # docker service ls # View created service
# will docker03 out of this cluster
[root @ docker03 ~] # docker swarm leave # docker03 out of this cluster
[root @ docker01 ~] # docker node rm docker03 # then removed docker03 on the role of manager server
[ root @ docker01 ~] # docker node promote docker02 # docker02 will upgrade from worker to manager.
# After the upgrade docker02 status to Reachable
[root @ docker01 ~] # Docker --availability Drain docker01 the Node Update
# do not run after setting the host docker01 container, but the container has been running and does not stop

Guess you like

Origin blog.51cto.com/14622097/2452846