03 - Centos7中安装及验证Docker

来源:互联网 发布:单纯的js做动态网站 编辑:程序博客网 时间:2024/06/16 08:19

安装

在Centos7中安装Docker非常简单,只需要一个命令:

yum -y install docker

而在Centos6的系统中安装Docker要相对复杂一些,首先需要将系统内核版本升级到3.10以上,其次需要通过使用命令yum update等升级操作系统,具体安装方法可参考文章《Centos 6.4中安装Docker》。

安装完成后需要启动docker服务:

systemctl start docker

验证

安装完成后需要验证docker服务是否安装成功和是否正常启动。

  • 验证版本信息
docker version

出现下面信息表示docker安装成功及正常启动:

[root@localhost ~]# docker versionClient: Version:         1.10.3 API version:     1.22 Package version: docker-common-1.10.3-46.el7.centos.14.x86_64 Go version:      go1.6.3 Git commit:      cb079f6-unsupported Built:           Fri Sep 16 13:24:25 2016 OS/Arch:         linux/amd64Server: Version:         1.10.3 API version:     1.22 Package version: docker-common-1.10.3-46.el7.centos.14.x86_64 Go version:      go1.6.3 Git commit:      cb079f6-unsupported Built:           Fri Sep 16 13:24:25 2016 OS/Arch:         linux/amd64[root@localhost ~]#

如果出现下面信息则表示只是安装成功而没有正常启动:

[root@localhost ~]# docker versionClient: Version:         1.10.3 API version:     1.22 Package version: docker-common-1.10.3-46.el7.centos.14.x86_64 Go version:      go1.6.3 Git commit:      cb079f6-unsupported Built:           Fri Sep 16 13:24:25 2016 OS/Arch:         linux/amd64Cannot connect to the Docker daemon. Is the docker daemon running on this host?

此时需要输入命令:systemctl start docker来启动docker服务。

  • 启动容器验证

输入命令:docker run hello-world

[root@localhost ~]# docker run hello-worldUnable to find image 'hello-world:latest' locallyTrying to pull repository docker.io/library/hello-world ...latest: Pulling from docker.io/library/hello-worldc04b14da8d14: Pull completeDigest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9Status: Downloaded newer image for docker.io/hello-world:latestHello from Docker!This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the    executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it    to your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker Hub account: https://hub.docker.comFor more examples and ideas, visit: https://docs.docker.com/engine/userguide/

出现上面信息表示安装成功!

0 0