Docker(一):安装

Docker中文官方网站

Docker镜像仓库

CentOS Docker安装条件

Docker支持以下的CentOS版本
  • CentOS 7 (64-bit) 系统内核版本3.10以上
  • CentOS 6.5 (64-bit)或更高版本 系统内核版本2.6.32-431或更高版本
## 查看内核版本
[root@localhost ~]# uname -r
3.10.0-693.el7.x86_64

## 查看已安装的CentOS的版本
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 

此处已centOS 7为例(初次安装,权限为root)

根据英文官方文档进行安装docker
中文官方文档

$ yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
$ yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
$ yum-config-manager --enable docker-ce-edge
$ yum-config-manager --enable docker-ce-test
$ yum-config-manager --disable docker-ce-edge
$ yum install docker-ce

至此,docker安装完毕

启动docker

$ systemctl start docker

随服务器启动

systemctl enable docker

设置docker镜像加速器

本例使用阿里云仓库

进入管理中心,使用淘宝账号登录

Docker(一):安装_第1张图片

点击“镜像加速器”,可以看到右边有个“加速器地址”

Docker(一):安装_第2张图片

1. 安装/升级Docker客户端
推荐安装1.10.0以上版本的Docker客户端,参考文档 docker-ce

2. 配置镜像加速器
针对Docker客户端版本大于 1.10.0 的用户

您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
vim /etc/docker/daemon.json
## 将下面的json写入
{
  "registry-mirrors": ["https://********.mirror.aliyuncs.com"]
}
## 保存后重启
systemctl daemon-reload
systemctl restart docker

测试hello world

# docker run hello-world
Unable to find image 'hello-world:latest' locally ## 显示本地没有该镜像,会从仓库拉取,并运行
latest: Pulling from library/hello-world
d1725b59e92d: Pull complete 
Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Status: Downloaded newer image for 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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

run流程图

Docker(一):安装_第3张图片

你可能感兴趣的:(Docker)