安裝
在Centos7中安裝Docker非常簡(jiǎn)單,只需要一個(gè)命令:
yum -y install docker
而在Centos6的系統(tǒng)中安裝Docker要相對(duì)復(fù)雜一些,首先需要將系統(tǒng)內(nèi)核版本升級(jí)到3.10以上,其次需要通過(guò)使用命令yum update等升級(jí)操作系統(tǒng),具體安裝方法可參考文章《Centos 6.4中安裝Docker》。
安裝完成后需要啟動(dòng)docker服務(wù):
systemctl start docker
驗(yàn)證
安裝完成后需要驗(yàn)證docker服務(wù)是否安裝成功和是否正常啟動(dòng)。
- 驗(yàn)證版本信息
docker version
出現(xiàn)下面信息表示docker安裝成功及正常啟動(dòng):
[root@localhost ~]# docker version
Client:
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
Server:
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 ~]#
如果出現(xiàn)下面信息則表示只是安裝成功而沒(méi)有正常啟動(dòng):
[root@localhost ~]# docker version
Client:
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
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
此時(shí)需要輸入命令:systemctl start docker來(lái)啟動(dòng)docker服務(wù)。
- 啟動(dòng)容器驗(yàn)證
輸入命令:docker run hello-world:
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
c04b14da8d14: Pull complete
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for docker.io/hello-world:latest
Hello 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 bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
出現(xiàn)上面信息表示安裝成功!