zoukankan      html  css  js  c++  java
  • docker 入门学习篇【基本命令与操作】

    [root@VM_225_102_centos ~]# docker version #查看版本
    Client:
     Version:      1.11.2
     API version:  1.23
     Go version:   go1.5.4
     Git commit:   b9f10c9
     Built:        Wed Jun  1 21:23:11 2016
     OS/Arch:      linux/amd64


    Server:
     Version:      1.11.2
     API version:  1.23
     Go version:   go1.5.4
     Git commit:   b9f10c9
     Built:        Wed Jun  1 21:23:11 2016
     OS/Arch:      linux/amd64

    ------------------------------------------------------------

    [root@VM_225_102_centos ~]# docker search ubuntu #搜索一个叫做ubuntu的镜像
    NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    ubuntu                            Ubuntu is a Debian-based Linux operating s...   4217      [OK]       
    ubuntu-upstart                    Upstart is an event-based replacement for ...   65        [OK]       
    rastasheep/ubuntu-sshd            Dockerized SSH service, built on top of of...   29                   [OK]

    ...

    ------------------------------------------------------------------------------------

    [root@VM_225_102_centos ~]# docker images  #查看本地docker镜像
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    hello-world         latest              c54a2cc56cbb        3 days ago          1.848 kB

    --------------------------------------------------------------------------------------------

    [root@VM_225_102_centos ~]# docker pull ubuntu #下载docker镜像
    Using default tag: latest
    latest: Pulling from library/ubuntu
    f069f1d21059: Downloading [============>                                      ] 12.18 MB/49.17 MB
    ecbeec5633cf: Download complete 
    ea6f18256d63: Download complete 
    54bde7b02897: Download complete 

    -------------------------------------------------------------------------------------------------------

    [root@VM_225_102_centos ~]# docker run ubuntu echo 'hello world' #在docker容器中运行hello world
    hello world

    -----------------------------------------------------------------------------------------------------

    ##交互式运行,crtl+D退出时,直接关闭vm1,若想该虚拟镜像后台运行,可执行crtl+p+q

    [root@VM_225_102_centos ~]# docker  run -it --name vm1 ubuntu bash # #
    root@ecd6467938f3:/#

    ----------------------------------------------------------------------------------------------------------------------------

    [root@VM_225_102_centos ~]# docker ps -a  ##查看建立的所有docker

    CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS                         PORTS               NAMES
    ecd6467938f3        ubuntu              "bash"                 3 minutes ago       Up 3 minutes                                       vm1
    46123b6e2b80        ubuntu              "echo 'hello world'"   5 minutes ago       Exited (0) 5 minutes ago                           drunk_borg
    ca8ba487aba3        ubuntu              "/bin/bash"            5 minutes ago       Exited (0) 5 minutes ago                           kickass_mestorf
    0176b65406da        hello-world         "/hello"               About an hour ago   Exited (0) About an hour ago                       thirsty_bardeen
    -------------------------------------------------------------------------------------------------------------

    [root@VM_225_102_centos ~]# docker ps         #查看正在运行的docker
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
    ecd6467938f3        ubuntu              "bash"              3 minutes ago       Up 3 minutes                            vm1

    -------------------------------------------------------------------------------------------------------------------------------------------------------

    [root@foundation45 ~]# docker stop vm1 ##停止vm1
    [root@foundation45 ~]# docker start vm1 ##启动vm1
    [root@foundation45 ~]# docker attach vm1 ##当vm1后台运行时,用该命令调回前台,可进入其bash命令行
    [root@foundation45 ~]# docker rm vm1 ##删除vm1


    -------------------------------------------------------------------------------------------------------------







  • 相关阅读:
    我们应当怎样做需求分析
    卓有成效的团队建设经验与见解 Team Leader你会带团队吗?
    一个独立程序员对自己近九个月工作生活的回顾
    KISS My YAGNI,KISS (Keep It Simple, Stupid)和 YAGNI (You Ain’t Gonna Need It)软件开发原则
    程序员新人如何在企业与人打好交道 站在别人的立场想问题,站在自己的立场做事情
    创业团队产品如何战胜大公司的抄袭 腾讯抄你肿么办?
    什么样的程序员才算成熟? 让程序员认清自己的所处的阶段
    HTML的GET方法传递参数样式。
    教您使用java爬虫gecco抓取JD全部商品信息
    JAVA 爬虫Gecco
  • 原文地址:https://www.cnblogs.com/tyzZ001/p/5657173.html
Copyright © 2011-2022 走看看