Centos7安装docker

Centos7安装docker

  • 1 系统要求
  • 2 yum更新
  • 3 卸载旧版本
  • 4 安装需要的软件包
  • 5 设置docker的安装源地址
  • 6 安装最新版本的Docker
  • 7 启动Docker并设置开机启动
  • 8 重启daemon并重启docker服务
  • 9 设置镜像的加速地址
  • 10 使用docker search 报超时的解决方法
    • 10.1 查看服务器DNS网络配置
    • 10.2 把里面的内容清除,并改为:
    • 10.3 重启网络服务
  • 11 Docker版本Jenkins的使用

1 系统要求

centos系统的内核必须高于3.10,可以通过以下命令查看系统内核。

uname -r

2 yum更新

yum update

3 卸载旧版本

yum remove docker docker-common docker-selinux docker-engine

4 安装需要的软件包

yum install -y yum-utils device-mapper-persistent-data lvm2

5 设置docker的安装源地址

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6 安装最新版本的Docker

yum install docker-ce docker-ce-cli containerd.io

7 启动Docker并设置开机启动

systemctl start docker

systemctl enable docker

8 重启daemon并重启docker服务

systemctl daemon-reload

systemctl restart docker

9 设置镜像的加速地址

vim /etc/docker/daemon.json

推荐优先使用阿里云的,阿里云的镜像加速需要自己去阿里云申请,这里填写的阿里云镜像加速地址非本人的:

{
"registry-mirrors": ["https://almtd3fa.mirror.aliyuncs.com","http://hub-mirror.c.163.com","http://mirrors.ustc.edu.cn"]
}

国内可用镜像源:

网易:http://hub-mirror.c.163.com
中科大镜像地址:http://mirrors.ustc.edu.cn
中科大github地址:https://github.com/ustclug/mirrorrequest
Azure中国镜像地址:http://mirror.azure.cn
Azure中国github地址:https://github.com/Azure/container-service-for-azure-china
DockerHub镜像仓库: https://hub.docker.com
阿里云镜像仓库:https://almtd3fa.mirror.aliyuncs.com(非本人)
google镜像仓库: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以的话是可以连上去的 )
coreos镜像仓库: https://quay.io/repository
RedHat镜像仓库: https://access.redhat.com/containers
使配置生效
systemctl daemon-reload

重启docker
systemctl restart docker

如果配置完重启后下载速度还是很慢,可以尝试用阿里云分配的镜像加速地址。

10 使用docker search 报超时的解决方法

10.1 查看服务器DNS网络配置

vi /etc/resolv.conf

10.2 把里面的内容清除,并改为:

nameserver 8.8.8.8

nameserver 8.8.8.4

10.3 重启网络服务

systemctl restart network

11 Docker版本Jenkins的使用

Docker版本Jenkins的使用

你可能感兴趣的:(docker,docker)