- CentOS 7 安装docker,要求系统必须为64位、系统内核版本为 3.10 以上。查看系统版本信息:
[root@JDu4e00u53f7 ~]# cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)
[root@JDu4e00u53f7 ~]# uname -r
3.10.0-693.11.6.el7.x86_64
- 安装docker
[root@JDu4e00u53f7 ~]# yum install docker -y
- 启动docker服务
[root@JDu4e00u53f7 ~]# systemctl start docker
[root@JDu4e00u53f7 ~]# docker version
Client:
Version: 1.13.1
API version: 1.26
Package version: <unknown>
Go version: go1.8.3
Git commit: 774336d/1.13.1
Built: Wed Mar 7 17:06:16 2018
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: <unknown>
Go version: go1.8.3
Git commit: 774336d/1.13.1
Built: Wed Mar 7 17:06:16 2018
OS/Arch: linux/amd64
Experimental: false
- 配置镜像加速
鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决.
[root@JDu4e00u53f7 ~]# vim /etc/docker/daemon.json
新增网易的docker镜像加速地址:
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
在这里我更推荐使用阿里云docker镜像加速,速度要比网易的更快。首先进入阿里云镜像库首页,点击管理中心:
复制加速器地址到
daemon.json
中,然后重启docker:
[root@JDu4e00u53f7 ~]# systemctl restart docker
- 测试运行 hello-world
[root@JDu4e00u53f7 ~]# 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:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
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.
(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/
To be continued...