• docker 学习操作记录 7


    记录5-2

      1 root@53d0a643a2c7:/# quit
      2 bash: quit: command not found
      3 root@53d0a643a2c7:/# exit
      4 exit
      5 -->@coder:~$ sudo docker container ls
      6 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
      7 -->@coder:~$ sudo docker run e76b /bin/sh -c "while true; do echo hello world; sleep 1; done"
      8 hello world
      9 hello world
     10 hello world
     11 hello world
     12 hello world
     13 ^C-->@coder:~$ sudo docker run -d e76b /bin/sh -c "while true; do echo hello world; sleep 1; done"
     14 e816e1fad8b66a483f2f83baccee4d3fc76747ab4ccfb16ae00b181d1934aaf6
     15 -->@coder:~$ sudo docker logs
     16 "docker logs" requires exactly 1 argument.
     17 See 'docker logs --help'.
     18 
     19 Usage:  docker logs [OPTIONS] CONTAINER
     20 
     21 Fetch the logs of a container
     22 -->@coder:~$ sudo docker logs --help
     23 
     24 Usage:    docker logs [OPTIONS] CONTAINER
     25 
     26 Fetch the logs of a container
     27 
     28 Options:
     29       --details        Show extra details provided to logs
     30   -f, --follow         Follow log output
     31       --since string   Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
     32       --tail string    Number of lines to show from the end of the logs (default "all")
     33   -t, --timestamps     Show timestamps
     34       --until string   Show logs before a timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
     35 -->@coder:~$ sudo docker logs -f
     36 "docker logs" requires exactly 1 argument.
     37 See 'docker logs --help'.
     38 
     39 Usage:  docker logs [OPTIONS] CONTAINER
     40 
     41 Fetch the logs of a container
     42 -->@coder:~$ sudo docker logs --details
     43 "docker logs" requires exactly 1 argument.
     44 See 'docker logs --help'.
     45 
     46 Usage:  docker logs [OPTIONS] CONTAINER
     47 
     48 Fetch the logs of a container
     49 -->@coder:~$ sudo docker ps
     50 CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS               NAMES
     51 e816e1fad8b6        e76b                "/bin/sh -c 'while t…"   About a minute ago   Up About a minute                       elated_meitner
     52 -->@coder:~$ sudo docker logs e816
     53 hello world
     54 hello world
     55 hello world
     56 hello world
     57 hello world
     58 -->@coder:~$ sudo docker ps -a
     59 CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                        PORTS                NAMES
     60 e816e1fad8b6        e76b                "/bin/sh -c 'while t…"   About a minute ago   Up About a minute                                  elated_meitner
     61 70b5e6a00101        e76b                "/bin/sh -c 'while t…"   2 minutes ago        Exited (0) 2 minutes ago                           wizardly_shaw
     62 53d0a643a2c7        e76b                "/bin/bash"              6 minutes ago        Exited (127) 3 minutes ago                         jovial_williams
     63 6771348f608f        e76b                "/bin/echo 'hello wo…"   7 minutes ago        Exited (0) 6 minutes ago                           flamboyant_shtern
     64 5a2a21ea4579        myweb:v1            "nginx -g 'daemon of…"   18 hours ago         Exited (255) 25 minutes ago   0.0.0.0:80->80/tcp   web
     65 0e83d3c0c655        231d40e811cd        "/bin/sh -c 'apt-get…"   18 hours ago         Exited (1) 18 hours ago                            sweet_satoshi
     66 18c8ffceebfb        myip                "-i"                     19 hours ago         Created                                            upbeat_satoshi
     67 3a2c6456820f        myip                "-i"                     19 hours ago         Created                                            distracted_lumiere
     68 a5acd4cc83ef        myip                "curl -s http://ip.cn"   19 hours ago         Exited (7) 19 hours ago                            brave_dewdney
     69 a279c8cb0430        nginx:v2            "nginx -g 'daemon of…"   21 hours ago         Exited (0) 18 hours ago                            web2
     70 e188b46041a5        nginx               "nginx -g 'daemon of…"   21 hours ago         Exited (0) 18 hours ago                            webserver
     71 -->@coder:~$ sudo docker container stop e816
     72 e816
     73 -->@coder:~$ sudo docker container ls
     74 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
     75 -->@coder:~$ sudo docker container ps
     76 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
     77 -->@coder:~$ sudo docker ps
     78 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
     79 -->@coder:~$ sudo docker container status
     80 
     81 Usage:    docker container COMMAND
     82 
     83 Manage containers
     84 
     85 Commands:
     86   attach      Attach local standard input, output, and error streams to a running container
     87   commit      Create a new image from a container's changes
     88   cp          Copy files/folders between a container and the local filesystem
     89   create      Create a new container
     90   diff        Inspect changes to files or directories on a container's filesystem
     91   exec        Run a command in a running container
     92   export      Export a container's filesystem as a tar archive
     93   inspect     Display detailed information on one or more containers
     94   kill        Kill one or more running containers
     95   logs        Fetch the logs of a container
     96   ls          List containers
     97   pause       Pause all processes within one or more containers
     98   port        List port mappings or a specific mapping for the container
     99   prune       Remove all stopped containers
    100   rename      Rename a container
    101   restart     Restart one or more containers
    102   rm          Remove one or more containers
    103   run         Run a command in a new container
    104   start       Start one or more stopped containers
    105   stats       Display a live stream of container(s) resource usage statistics
    106   stop        Stop one or more running containers
    107   top         Display the running processes of a container
    108   unpause     Unpause all processes within one or more containers
    109   update      Update configuration of one or more containers
    110   wait        Block until one or more containers stop, then print their exit codes
    111 
    112 Run 'docker container COMMAND --help' for more information on a command.
    113 -->@coder:~$ sudo docker container stats
    114 CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
    115 CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
    116 CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
    117 q
    118 CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
    119 -->@coder:~$ sudo docker container
    120 
    121 Usage:    docker container COMMAND
    122 
    123 Manage containers
    124 
    125 Commands:
    126   attach      Attach local standard input, output, and error streams to a running container
    127   commit      Create a new image from a container's changes
    128   cp          Copy files/folders between a container and the local filesystem
    129   create      Create a new container
    130   diff        Inspect changes to files or directories on a container's filesystem
    131   exec        Run a command in a running container
    132   export      Export a container's filesystem as a tar archive
    133   inspect     Display detailed information on one or more containers
    134   kill        Kill one or more running containers
    135   logs        Fetch the logs of a container
    136   ls          List containers
    137   pause       Pause all processes within one or more containers
    138   port        List port mappings or a specific mapping for the container
    139   prune       Remove all stopped containers
    140   rename      Rename a container
    141   restart     Restart one or more containers
    142   rm          Remove one or more containers
    143   run         Run a command in a new container
    144   start       Start one or more stopped containers
    145   stats       Display a live stream of container(s) resource usage statistics
    146   stop        Stop one or more running containers
    147   top         Display the running processes of a container
    148   unpause     Unpause all processes within one or more containers
    149   update      Update configuration of one or more containers
    150   wait        Block until one or more containers stop, then print their exit codes
    151 
    152 Run 'docker container COMMAND --help' for more information on a command.
    153 -->@coder:~$ 
    154 -->@coder:~$ sudo docker container ls
    155 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    156 -->@coder:~$ sudo docker ps
    157 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    158 -->@coder:~$ sudo docker ps -a
    159 CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                        PORTS                NAMES
    160 e816e1fad8b6        e76b                "/bin/sh -c 'while t…"   6 minutes ago       Exited (137) 3 minutes ago                         elated_meitner
    161 70b5e6a00101        e76b                "/bin/sh -c 'while t…"   7 minutes ago       Exited (0) 6 minutes ago                           wizardly_shaw
    162 53d0a643a2c7        e76b                "/bin/bash"              11 minutes ago      Exited (127) 8 minutes ago                         jovial_williams
    163 6771348f608f        e76b                "/bin/echo 'hello wo…"   11 minutes ago      Exited (0) 11 minutes ago                          flamboyant_shtern
    164 5a2a21ea4579        myweb:v1            "nginx -g 'daemon of…"   18 hours ago        Exited (255) 30 minutes ago   0.0.0.0:80->80/tcp   web
    165 0e83d3c0c655        231d40e811cd        "/bin/sh -c 'apt-get…"   19 hours ago        Exited (1) 19 hours ago                            sweet_satoshi
    166 18c8ffceebfb        myip                "-i"                     19 hours ago        Created                                            upbeat_satoshi
    167 3a2c6456820f        myip                "-i"                     19 hours ago        Created                                            distracted_lumiere
    168 a5acd4cc83ef        myip                "curl -s http://ip.cn"   19 hours ago        Exited (7) 19 hours ago                            brave_dewdney
    169 a279c8cb0430        nginx:v2            "nginx -g 'daemon of…"   21 hours ago        Exited (0) 18 hours ago                            web2
    170 e188b46041a5        nginx               "nginx -g 'daemon of…"   21 hours ago        Exited (0) 18 hours ago                            webserver
    171 -->@coder:~$ sudo docker run -idt ubuntu
    172 Unable to find image 'ubuntu:latest' locally
    173 latest: Pulling from library/ubuntu
    174 
    175 
    176 
    177 
    178 Digest: sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d
    179 Status: Downloaded newer image for ubuntu:latest
    180 ae3899f543f7025e4d9cadf562c80f364e162346f0241928a5dd865e7d198988
    181 -->@coder:~$ sudo docker ps
    182 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    183 ae3899f543f7        ubuntu              "/bin/bash"         17 seconds ago      Up 15 seconds                           mystifying_bardeen
    184 -->@coder:~$ sudo docker attach mystifying_bardeen
    185 root@ae3899f543f7:/# exit
    186 exit
    187 -->@coder:~$ sudo whereis nsenter
    188 nsenter: /usr/bin/nsenter /usr/share/man/man1/nsenter.1.gz
    189 -->@coder:~$ sudo docker ps
    190 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    191 -->@coder:~$ sudo docker ps -a
    192 CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                          PORTS                NAMES
    193 ae3899f543f7        ubuntu              "/bin/bash"              3 minutes ago       Exited (0) About a minute ago                        mystifying_bardeen
    194 e816e1fad8b6        e76b                "/bin/sh -c 'while t…"   15 minutes ago      Exited (137) 12 minutes ago                          elated_meitner
    195 70b5e6a00101        e76b                "/bin/sh -c 'while t…"   16 minutes ago      Exited (0) 15 minutes ago                            wizardly_shaw
    196 53d0a643a2c7        e76b                "/bin/bash"              20 minutes ago      Exited (127) 17 minutes ago                          jovial_williams
    197 6771348f608f        e76b                "/bin/echo 'hello wo…"   20 minutes ago      Exited (0) 20 minutes ago                            flamboyant_shtern
    198 5a2a21ea4579        myweb:v1            "nginx -g 'daemon of…"   19 hours ago        Exited (255) 39 minutes ago     0.0.0.0:80->80/tcp   web
    199 0e83d3c0c655        231d40e811cd        "/bin/sh -c 'apt-get…"   19 hours ago        Exited (1) 19 hours ago                              sweet_satoshi
    200 18c8ffceebfb        myip                "-i"                     19 hours ago        Created                                              upbeat_satoshi
    201 3a2c6456820f        myip                "-i"                     19 hours ago        Created                                              distracted_lumiere
    202 a5acd4cc83ef        myip                "curl -s http://ip.cn"   19 hours ago        Exited (7) 19 hours ago                              brave_dewdney
    203 a279c8cb0430        nginx:v2            "nginx -g 'daemon of…"   21 hours ago        Exited (0) 19 hours ago                              web2
    204 e188b46041a5        nginx               "nginx -g 'daemon of…"   22 hours ago        Exited (0) 19 hours ago                              webserver
    205 -->@coder:~$ man nsenter
    206 NSENTER(1)                                                                        User Commands                                                                       NSENTER(1)
    207 
    208 NAME
    209        nsenter - run program with namespaces of other processes
    210 
    211 SYNOPSIS
    212        nsenter [options] [program [arguments]]
    213 
    214 DESCRIPTION
    215        Enters the namespaces of one or more other processes and then executes the specified program.  Enterable namespaces are:
    216 
    217        mount namespace
    218               Mounting  and unmounting filesystems will not affect the rest of the system (CLONE_NEWNS flag), except for filesystems which are explicitly marked as shared (with
    219               mount --make-shared; see /proc/self/mountinfo for the shared flag).
    220 
    221        UTS namespace
    222               Setting hostname or domainname will not affect the rest of the system.  (CLONE_NEWUTS flag)
    223 
    224        IPC namespace
    225               The process will have an independent namespace for System V message queues, semaphore sets and shared memory segments.  (CLONE_NEWIPC flag)
    226 
    227        network namespace
    228               The process will have independent IPv4 and IPv6 stacks, IP routing tables, firewall rules,  the  /proc/net  and  /sys/class/net  directory  trees,  sockets,  etc.
    229               (CLONE_NEWNET flag)
    230 
    231        PID namespace
    232               Children  will  have  a  set  of  PID to process mappings separate from the nsenter process (CLONE_NEWPID flag).  nsenter will fork by default if changing the PID
    233               namespace, so that the new program and its children share the same PID namespace and are visible to each other.  If --no-fork is used, the  new  program  will  be
    234               exec'ed without forking.
    235 
    236        user namespace
    237               The process will have a distinct set of UIDs, GIDs and capabilities.  (CLONE_NEWUSER flag)
    238 
    239        See clone(2) for the exact semantics of the flags.
    240 
    241        If program is not given, then ``${SHELL}'' is run (default: /bin/sh).
    242 
    243 OPTIONS
    244        -t, --target pid
    245               Specify a target process to get contexts from.  The paths to the contexts specified by pid are:
    246 
    247               /proc/pid/ns/mnt    the mount namespace
    248               /proc/pid/ns/uts    the UTS namespace
    249               /proc/pid/ns/ipc    the IPC namespace
    250               /proc/pid/ns/net    the network namespace
    251               /proc/pid/ns/pid    the PID namespace
    252               /proc/pid/ns/user   the user namespace
    253               /proc/pid/root      the root directory
    254               /proc/pid/cwd       the working directory respectively
    255 
    256        -m, --mount[=file]
    257               Enter  the  mount namespace.  If no file is specified, enter the mount namespace of the target process.  If file is specified, enter the mount namespace specified
    258               by file.
    259 
    260        -u, --uts[=file]
    261               Enter the UTS namespace.  If no file is specified, enter the UTS namespace of the target process.  If file is specified, enter  the  UTS  namespace  specified  by
    262               file.
    263 
    264        -i, --ipc[=file]
    265               Enter  the  IPC  namespace.   If  no file is specified, enter the IPC namespace of the target process.  If file is specified, enter the IPC namespace specified by
    266               file.
    267 
    268        -n, --net[=file]
    269               Enter the network namespace.  If no file is specified, enter the network namespace of the target process.  If file is specified, enter the network namespace spec‐
    270               ified by file.
    271 
    272        -p, --pid[=file]
    273               Enter  the  PID  namespace.   If  no file is specified, enter the PID namespace of the target process.  If file is specified, enter the PID namespace specified by
    274               file.
    275 
    276        -U, --user[=file]
    277               Enter the user namespace.  If no file is specified, enter the user namespace of the target process.  If file is specified, enter the user namespace  specified  by
    278               file.  See also the --setuid and --setgid options.
    279 
    280        -G, --setgid gid
    281               Set the group ID which will be used in the entered namespace and drop supplementary groups.  nsenter(1) always sets GID for user namespaces, the default is 0.
    282 
    283        -S, --setuid uid
    284               Set the user ID which will be used in the entered namespace.  nsenter(1) always sets UID for user namespaces, the default is 0.
    285 
    286        --preserve-credentials
    287               Don't modify UID and GID when enter user namespace. The default is to drops supplementary groups and sets GID and UID to 0.
    288 
    289        -r, --root[=directory]
    290               Set  the  root  directory.   If no directory is specified, set the root directory to the root directory of the target process.  If directory is specified, set the
    291               root directory to the specified directory.
    292 
    293        -w, --wd[=directory]
    294               Set the working directory.  If no directory is specified, set the working directory to the working directory of the target process.  If  directory  is  specified,
    295               set the working directory to the specified directory.
    296 
    297        -F, --no-fork
    298               Do  not  fork  before exec'ing the specified program.  By default, when entering a PID namespace, nsenter calls fork before calling exec so that any children will
    299               also be in the newly entered PID namespace.
    300 
    301        -Z, --follow-context
    302               Set the SELinux security context used for executing a new process according to already running process specified by --target PID. (The util-linux has to  be  com‐
    303               piled with SELinux support otherwise the option is unavailable.)
    304 
    305        -V, --version
    306               Display version information and exit.
    307 
    308        -h, --help
    309               Display help text and exit.
    310 
    311 SEE ALSO
    312        setns(2), clone(2)
    313 
    314 AUTHORS
    315        Eric Biederman ⟨biederm@xmission.com⟩
    316        Karel Zak ⟨kzak@redhat.com⟩
    317 
    318 AVAILABILITY
    319        The nsenter command is part of the util-linux package and is available from Linux Kernel Archive ⟨ftp://ftp.kernel.org/pub/linux/utils/util-linux/⟩.
    320 
    321 util-linux                                                                          June 2013                                                                         NSENTER(1)
    322 -->@coder:~$ docker inspect --format "{{ .State.Pid }}" myip
    323 unknown shorthand flag: 'm' in -myip
    324 See 'docker inspect --help'.
    325 -->@coder:~$ sudo docker run -idt ubuntu
    326 8cb6ebee1aa1e62cd0cf4c870d210c1033f5e559b950c9121cf597f798bfdf71
    327 -->@coder:~$ sudo docker ps
    328 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    329 8cb6ebee1aa1        ubuntu              "/bin/bash"         7 seconds ago       Up 5 seconds                            jolly_cannon
    330 -->@coder:~$ PID=$(sudo docker-pid 8cb6)
    331 sudo: docker-pid:找不到命令
    332 -->@coder:~$ PID=$(sudo docker -pid 8cb6)
    333 unknown shorthand flag: 'p' in -pid
    334 See 'docker --help'.
    335 
    336 Usage:    docker [OPTIONS] COMMAND
    337 
    338 A self-sufficient runtime for containers
    339 
    340 Options:
    341       --config string      Location of client config files (default "/home/coder/.docker")
    342   -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
    343   -D, --debug              Enable debug mode
    344   -H, --host list          Daemon socket(s) to connect to
    345   -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
    346       --tls                Use TLS; implied by --tlsverify
    347       --tlscacert string   Trust certs signed only by this CA (default "/home/coder/.docker/ca.pem")
    348       --tlscert string     Path to TLS certificate file (default "/home/coder/.docker/cert.pem")
    349       --tlskey string      Path to TLS key file (default "/home/coder/.docker/key.pem")
    350       --tlsverify          Use TLS and verify the remote
    351   -v, --version            Print version information and quit
    352 
    353 Management Commands:
    354   builder     Manage builds
    355   config      Manage Docker configs
    356   container   Manage containers
    357   context     Manage contexts
    358   engine      Manage the docker engine
    359   image       Manage images
    360   network     Manage networks
    361   node        Manage Swarm nodes
    362   plugin      Manage plugins
    363   secret      Manage Docker secrets
    364   service     Manage services
    365   stack       Manage Docker stacks
    366   swarm       Manage Swarm
    367   system      Manage Docker
    368   trust       Manage trust on Docker images
    369   volume      Manage volumes
    370 
    371 Commands:
    372   attach      Attach local standard input, output, and error streams to a running container
    373   build       Build an image from a Dockerfile
    374   commit      Create a new image from a container's changes
    375   cp          Copy files/folders between a container and the local filesystem
    376   create      Create a new container
    377   diff        Inspect changes to files or directories on a container's filesystem
    378   events      Get real time events from the server
    379   exec        Run a command in a running container
    380   export      Export a container's filesystem as a tar archive
    381   history     Show the history of an image
    382   images      List images
    383   import      Import the contents from a tarball to create a filesystem image
    384   info        Display system-wide information
    385   inspect     Return low-level information on Docker objects
    386   kill        Kill one or more running containers
    387   load        Load an image from a tar archive or STDIN
    388   login       Log in to a Docker registry
    389   logout      Log out from a Docker registry
    390   logs        Fetch the logs of a container
    391   pause       Pause all processes within one or more containers
    392   port        List port mappings or a specific mapping for the container
    393   ps          List containers
    394   pull        Pull an image or a repository from a registry
    395   push        Push an image or a repository to a registry
    396   rename      Rename a container
    397   restart     Restart one or more containers
    398   rm          Remove one or more containers
    399   rmi         Remove one or more images
    400   run         Run a command in a new container
    401   save        Save one or more images to a tar archive (streamed to STDOUT by default)
    402   search      Search the Docker Hub for images
    403   start       Start one or more stopped containers
    404   stats       Display a live stream of container(s) resource usage statistics
    405   stop        Stop one or more running containers
    406   tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
    407   top         Display the running processes of a container
    408   unpause     Unpause all processes within one or more containers
    409   update      Update configuration of one or more containers
    410   version     Show the Docker version information
    411   wait        Block until one or more containers stop, then print their exit codes
    412 
    413 Run 'docker COMMAND --help' for more information on a command.
    414 
    415 -->@coder:~$ sudo docker --help
    416 
    417 Usage:    docker [OPTIONS] COMMAND
    418 
    419 A self-sufficient runtime for containers
    420 
    421 Options:
    422       --config string      Location of client config files (default "/home/coder/.docker")
    423   -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
    424   -D, --debug              Enable debug mode
    425   -H, --host list          Daemon socket(s) to connect to
    426   -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
    427       --tls                Use TLS; implied by --tlsverify
    428       --tlscacert string   Trust certs signed only by this CA (default "/home/coder/.docker/ca.pem")
    429       --tlscert string     Path to TLS certificate file (default "/home/coder/.docker/cert.pem")
    430       --tlskey string      Path to TLS key file (default "/home/coder/.docker/key.pem")
    431       --tlsverify          Use TLS and verify the remote
    432   -v, --version            Print version information and quit
    433 
    434 Management Commands:
    435   builder     Manage builds
    436   config      Manage Docker configs
    437   container   Manage containers
    438   context     Manage contexts
    439   engine      Manage the docker engine
    440   image       Manage images
    441   network     Manage networks
    442   node        Manage Swarm nodes
    443   plugin      Manage plugins
    444   secret      Manage Docker secrets
    445   service     Manage services
    446   stack       Manage Docker stacks
    447   swarm       Manage Swarm
    448   system      Manage Docker
    449   trust       Manage trust on Docker images
    450   volume      Manage volumes
    451 
    452 Commands:
    453   attach      Attach local standard input, output, and error streams to a running container
    454   build       Build an image from a Dockerfile
    455   commit      Create a new image from a container's changes
    456   cp          Copy files/folders between a container and the local filesystem
    457   create      Create a new container
    458   diff        Inspect changes to files or directories on a container's filesystem
    459   events      Get real time events from the server
    460   exec        Run a command in a running container
    461   export      Export a container's filesystem as a tar archive
    462   history     Show the history of an image
    463   images      List images
    464   import      Import the contents from a tarball to create a filesystem image
    465   info        Display system-wide information
    466   inspect     Return low-level information on Docker objects
    467   kill        Kill one or more running containers
    468   load        Load an image from a tar archive or STDIN
    469   login       Log in to a Docker registry
    470   logout      Log out from a Docker registry
    471   logs        Fetch the logs of a container
    472   pause       Pause all processes within one or more containers
    473   port        List port mappings or a specific mapping for the container
    474   ps          List containers
    475   pull        Pull an image or a repository from a registry
    476   push        Push an image or a repository to a registry
    477   rename      Rename a container
    478   restart     Restart one or more containers
    479   rm          Remove one or more containers
    480   rmi         Remove one or more images
    481   run         Run a command in a new container
    482   save        Save one or more images to a tar archive (streamed to STDOUT by default)
    483   search      Search the Docker Hub for images
    484   start       Start one or more stopped containers
    485   stats       Display a live stream of container(s) resource usage statistics
    486   stop        Stop one or more running containers
    487   tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
    488   top         Display the running processes of a container
    489   unpause     Unpause all processes within one or more containers
    490   update      Update configuration of one or more containers
    491   version     Show the Docker version information
    492   wait        Block until one or more containers stop, then print their exit codes
    493 
    494 Run 'docker COMMAND --help' for more information on a command.
    495 -->@coder:~$ sudo docker ps
    496 CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    497 8cb6ebee1aa1        ubuntu              "/bin/bash"         5 minutes ago       Up 5 minutes                            jolly_cannon
    498 -->@coder:~$ PID=$(sudo docker inspect --format "{{ .State.Pid}}" 8cb6)
    499 -->@coder:~$ PID=$(sudo docker inspect --format "{{ .State.Pid}}" jolly_cannon)
    500 -->@coder:~$ echo PID
    501 PID
    502 -->@coder:~$ echo $PID
    503 6333
    504 -->@coder:~$ XID=$(sudo docker inspect --format "{{ .State.Pid}}" 8cb6)
    505 -->@coder:~$ echo ${XID}
    506 6333
    507 -->@coder:~$ man docker-pid
    508 没有 docker-pid 的手册页条目
    509 -->@coder:~$ sudo apt-get docker-pid
    510 E: 无效的操作 docker-pid
    511 -->@coder:~$ sudo apt-cache search docker-pid
    512 -->@coder:~$ sudo nsenter --target $PID --mount --uts --ipc --net --pid
    513 root@8cb6ebee1aa1:/# pwd
    514 /
    515 root@8cb6ebee1aa1:/# ls
    516 bin  boot  dev    etc  home  lib    lib64  media  mnt  opt    proc  root  run  sbin  srv  sys  tmp  usr  var
    517 root@8cb6ebee1aa1:/# echo $SHELL
    518 /bin/bash
    519 root@8cb6ebee1aa1:/# exit
    520 logout
    521 -->@coder:~$ wget -P ~ https://github.com/yeasy/docker_practice/raw/master/
    522 --2019-12-05 11:25:49--  https://github.com/yeasy/docker_practice/raw/master/
    523 正在解析主机 github.com (github.com)... 52.74.223.119
    524 正在连接 github.com (github.com)|52.74.223.119|:443... 已连接。
    525 已发出 HTTP 请求,正在等待回应... 404 Not Found
    526 2019-12-05 11:25:51 错误 404:Not Found。
    527 
    528 -->@coder:~$ _local/.bashrc_docker;
    529 -su: _local/.bashrc_docker: 没有那个文件或目录
    530 -->@coder:~$ man wget
    531 WGET(1)                                                                             GNU Wget                                                                             WGET(1)
    532 
    533 NAME
    534        Wget - The non-interactive network downloader.
    535 
    536 SYNOPSIS
    537        wget [option]... [URL]...
    538 
    539 WGET(1)                                                                             GNU Wget                                                                             WGET(1)
    540 
    541 NAME
    542        Wget - The non-interactive network downloader.
    543 
    544 SYNOPSIS
    545        wget [option]... [URL]...
    546 
    547 WGET(1)                                                                             GNU Wget                                                                             WGET(1)
    548 
    549 NAME
    550        Wget - The non-interactive network downloader.
    551 
    552 SYNOPSIS
    553        wget [option]... [URL]...
    554 
    555 ...skipping...
    556            If you just want to get rid of the directory structure, this option is similar to a combination of -nd and -P.  However, unlike -nd, --cut-dirs does not lose with
    557            subdirectories---for instance, with -nH --cut-dirs=1, a beta/ subdirectory will be placed to xemacs/beta, as one would expect.
    558 
    559        -P prefix
    560        --directory-prefix=prefix
    561            Set directory prefix to prefix.  The directory prefix is the directory where all other files and subdirectories will be saved to, i.e. the top of the retrieval tree.
    562            The default is . (the current directory).
    563 
    564 
    565 [END] 2019/12/5 11:29:32
  • 相关阅读:
    给图片加自定义字体水印
    [ZT]互联网网站应该如何存储密码?
    【Best Practice】在JAVA里面反序列化.NET的对象。
    关于权限验证的两篇好文
    U盘安装Ubuntu遇到的奇怪问题
    const 用法
    程序员进级攻略
    搞混的指针数组与数组指针
    C/C++内存分配
    多个常见代码设计缺陷(转载)
  • 原文地址:https://www.cnblogs.com/shuitian-ys/p/11994112.html
Copyright © 2020-2023  润新知