Docker支持以下的CentOS版本:
CentOS 7 (64-bit)
CentOS 6.5 (64-bit) 或更高的版本
建议:
Docker 运行在 CentOS 7 上,要求系统为64位、系统内核版本为 3.10 以上。
Docker 运行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系统为64位、系统内核版本为 2.6.32-431 或者更高版本。
查看内核版本:
[root@test ~]# uname -r
3.10.0-514.26.2.el7.x86_64
安装Docker:
[root@test ~]# yum -y install docker
最后输出这些即是安装完成
Installed:
docker.x86_64 2:1.12.6-68.gitec8512b.el7.centos
Dependency Installed:
container-selinux.noarch 2:2.33-1.git86f33cd.el7 container-storage-setup.noarch 0:0.8.0-3.git1d27ecf.el7 docker-client.x86_64 2:1.12.6-68.gitec8512b.el7.centos docker-common.x86_64 2:1.12.6-68.gitec8512b.el7.centos
oci-register-machine.x86_64 1:0-3.13.gitcd1e331.el7 oci-systemd-hook.x86_64 1:0.1.14-1.git1ba44c6.el7 oci-umount.x86_64 2:2.3.0-1.git51e7c50.el7 skopeo-containers.x86_64 1:0.1.26-2.dev.git2e8377a.el7.centos
Complete!
启动Docker后台服务
[root@test ~]# service docker start
Redirecting to /bin/systemctl start docker.service
测试运行helloworld
[root@test ~]# 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
ca4f61b1923c: Pull complete
Digest: sha256:4a8b4aa0b2d025dd6aad41d36e5d45b2fee996f27fe49dd130d9afefe7a8f7cd
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.
(amd64)
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 ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
由于本地没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行。
使用脚本安装 Docker
1、使用 sudo 或 root 权限登录 Centos。
2、确保 yum 包更新到最新。
$ sudo yum update
3、执行 Docker 安装脚本。
$ curl -fsSL https://get.docker.com/ | sh
执行这个脚本会添加 docker.repo 源并安装 Docker。
4、启动 Docker 进程。
$ sudo service docker start
5、验证 docker 是否安装成功并在容器中执行一个测试的镜像。
$ sudo docker run hello-world
CentOS 系统的Docker安装完成
Ubuntu安装docker
wget -qO- https://get.docker.com/ | sh