[Application] Docker commonly used commands (three)

Docker commonly used commands

info|version

  1、info

    docker info: Docker display system information, and a container comprising a number of mirrors

    Syntax: Docker info [ the OPTIONS ]

    Example: Docker Info

  2、version

    docker version: Docker display version information.

    Syntax: Docker Version [ the OPTIONS ]

    OPTIONS Description:

      -f: Specifies the return value of the template file.

    例:docker version

Mirroring Command

  1、images

    docker images:  lists local mirror.

    Syntax: Docker ImagesRF Royalty Free [ the OPTIONS ] [ the REPOSITORY [: TAG ]]

    OPTIONS Description:

      -a: List all the local mirror (image-containing intermediate layer, by default, the intermediate filtered image layer);

      --digests: displays summary information mirror;

      -f: Display image satisfies the conditions;  

      --format: Specifies the return value of the template file;

      --no-trunc: display the full image information;

      -q: Show only image ID.

    例:docker images

  2、search

    docker search:  Find a mirror from Docker Hub

    语法:docker search [OPTIONS] TERM

    OPTIONS Description:

      --automated: list only automated build type mirror;

      --no-trunc: display the full image description;

      -s: lists the subscription number is not less than the specified value of the mirror.

    例:docker search tomcat

  3、pull

    docker pull:  pulling or update the specified image from the image repository

    Syntax: Docker pull [ the OPTIONS ] NAME [: TAG | @DIGEST ]

    OPTIONS Description:

      -a: pulling all tagged image

       --disable-content-trust: Ignore checking the mirror, turned on by default

    例:docker pull tomcat

  4、rmi

    docker rmi:  delete a local number or a mirror.

    Syntax: Docker rmi [ the OPTIONS ] the IMAGE [ the IMAGE ...]

    OPTIONS Description:

      -f: force the removal;

      --no-prune: process without removing the mirror image, the default is removed;

    例:docker rmi tomcat

Container command

  1、run

    docker run: create a new container and run a command

    语法:docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

    OPTIONS Description:

      -a stdin: Specifies the standard input and output content types, optionally STDIN / STDOUT / STDERR three;
      -d: background container, and returns the container ID;
      -i: Run vessel in interactive mode, typically used in conjunction with -t;
      - P: random port mapping, the container inner mapped to the host port random high port
      -p: Specifies port mapping format: a host (host) port: the port of the container
      -t: reassign a pseudo input terminal is a container, generally -i use;
      --name = "Nginx-LB": a name container;
      - DNS 8.8.8.8: DNS server specifies the use of containers, and consistent with the default host;
      - DNS-Search the example.com: DNS specified container search domain, and the same default host;
      -H "Mars": hostname specified container;
      -e username = "Ritchie": set the environment variable;
      --env-file = []: read a file from the specified environment variable;
      - cpuset = "0-2" or --cpuset = "0,1,2": bind to a designated container CPU operation;
      -m: memory maximum use of the container is provided;
      - net = "Bridge": network specified container connection types, support for bridge / host / none / container:Four types;
      --link = []: add a link to another vessel;
      --expose = []: opening a port or a group of ports;
      --volume, -v: a bound volume

    例:docker -it -p 8888:8080 -name mytomcat tomcat

  2、ps

    docker ps:  list container

    Syntax: Docker PS [ the OPTIONS ]

    OPTIONS Description:

      -a: shows all containers, including not running.

      -f: filtering content displayed according to the conditions.

      --format: Specifies the return value of the template file.

      -l: display container recently created.

      -n: list n containers recently created.

      --no-trunc: do not cut output.

      -q: Silent mode, only the container number.

      -s: Displays the total file size.

    Example: Docker Ps

  3、exit

    exit: execution in a container, the container exit

    Example: Exit

  4、start/stop/restart

    Start Docker  : starting one or more containers has been stopped

    STOP Docker  : Stop a running container

    restart Docker  : Restart container

    语法:docker start [OPTIONS] CONTAINER [CONTAINER...]

    例:docker restart mytomcat

  5、kill 

    the kill Docker  : a container kill operation.

    语法:docker kill [OPTIONS] CONTAINER [CONTAINER...]

    OPTIONS Description:

      -s: sending a signal to the container

    例:docker kill -s mytomcat

  6、rm

    docker rm: remove one or more containers.

    例:docker rm mytomcat

  7、logs

    docker logs:  obtaining container logs

    Syntax: Docker logs [ the OPTIONS ] CONTAINER

    例:docker logs -f mytomcat

  8、top

    docker top: View process information running in the container to support the ps command parameters.

    Syntax: Docker Top [ the OPTIONS ] CONTAINER [ PS the OPTIONS ]

    There is not necessarily a container runtime / bin / bash terminal to interact with the top command execution, and the container is not necessarily the top command can be used to implement the process docker top view the container in the running.

    例:docker top mytomcat

  9、inspect

    docker inspect:  acquiring metadata container / mirror.

    语法:docker inspect [OPTIONS] NAME|ID [NAME|ID...]

    例:docker inspect mytomcat

  9、exec

    docker exec: execute commands in running container

    语法:docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

    OPTIONS Description:

      -d: Split mode: running in the background

      -i: Even without additional remains open STDIN

      -t: assign a pseudo-terminal

    例:docker exec -it mytomcat /bin/bash

  10、build

    docker build  command is used to create a mirror using Dockerfile.

    例:docker build -f dockerfile -t test/mycentos .

Container rootfs command

  1、cp 

    docker cp: a data copy between the container and the host.

    grammar:

      docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-

      docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

    Example:

      The host / www / runoob copied to the directory / www directory 96f7f14e99ab the container.

      docker cp /www/runoob 96f7f14e99ab:/www/

      The container of 96f7f14e99ab / www copy of the directory to the host the / tmp directory.

      docker cp  96f7f14e99ab:/www /tmp/

  2、commit

    docker commit: to create a new image from the container.

    例:docker commit -a "H__D" -m="my tomcat with index.html" 9c0b5af58bd6 test/mytomcat:1.0

 

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/h--d/p/12563452.html