• Docker(二):Hello World


    Docker 安装

    这里以CentOS7 为例,其他安装教程可以自行通过其他路径了解。

    Docker 运行在CentOS7 上要求,系统为64位、系统内核版本为3.10以上。

    Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。

    安装前提条件

    安装Docker 之前先确定系统内核版本是否高于3.10.可以通过uname -r命令查看:

    [root@localhost ~]# uname -r
    3.10.0-327.el7.x86_64

    如上结果所示,内核版本为3.10.0,则可以安装Docker,如果你的内核版本低于3.10.0那么请使用yum update命令,进行升级。

    安装Docker

    安装Docker只需要执行yum install docker 命令即可。然后输入y确定安装。

    [root@localhost ~]# yum install docker

    启动Docker

    启动docker 只需要执行systemctl start docker 命令

    [root@localhost ~]#  systemctl start docker

    如果你想开启自动启动docker可以使用 systemctl enable docker.service 命令

    [root@localhost ~]# systemctl enable docker.service

    查看Docker版本

    执行docker version 可以查看docker版本信息。里面包括客服端和服务器的版本信息。

    [root@localhost ~]# docker version
    Client:
     Version:         1.13.1
     API version:     1.26
     Package version: docker-1.13.1-63.git94f4240.el7.centos.x86_64
     Go version:      go1.9.4
     Git commit:      94f4240/1.13.1
     Built:           Fri May 18 15:44:33 2018
     OS/Arch:         linux/amd64
    
    Server:
     Version:         1.13.1
     API version:     1.26 (minimum version 1.12)
     Package version: docker-1.13.1-63.git94f4240.el7.centos.x86_64
     Go version:      go1.9.4
     Git commit:      94f4240/1.13.1
     Built:           Fri May 18 15:44:33 2018
     OS/Arch:         linux/amd64
     Experimental:    false

    Hello world

    下载Hello world 镜像文件,执行命令 docker pull  hello-world 命令,进行下载hello world 镜像文件。

    [root@localhost ~]# docker pull hello-world
    Using default tag: latest
    Trying to pull repository docker.io/library/hello-world ... 
    latest: Pulling from docker.io/library/hello-world
    9bb5a5d4561a: Pull complete 
    Digest: sha256:3e1764d0f546ceac4565547df2ac4907fe46f007ea229fd7ef2718514bcec35d
    Status: Downloaded newer image for docker.io/hello-world:latest

    查看镜像文件使用命令docker images,可以查看所有的镜像文件。

    [root@localhost ~]# docker images
    REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
    docker.io/hello-world   latest              e38bc07ac18e        2 months ago        1.85 kB

    可以看到镜像的名称docker.io/hello-world,镜像的TAG版本为latest表示最新版本,IMAGE ID 表示镜像的ID,CREATE 表示镜像穿件时间, SIZE 表示镜像大小。

    运行镜像文件,使用docker run命令执行 后面可以带 镜像名 或 镜像ID。

    [root@localhost ~]# docker run hello-world
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    ...

    如上表示执行成功,并打印 Hello from Docker 等等信息。

  • 相关阅读:
    电子书《数字化转型领导者的技术修养》免费下载
    数字签名
    C:条件编译
    轻量级日志收集方案Loki
    安装Kubernetes(k8s)保姆级教程---无坑版
    设计模式七大原则-迪米特法则
    设计模式七大原则-开闭原则
    设计模式七大原则-里氏替换原则
    deepin-terminal改造风云再起
    deepin-terminal再改造
  • 原文地址:https://www.cnblogs.com/peter1018/p/9244762.html
Copyright © 2020-2023  润新知