Docker安装说明详细

Docker安装

1.前置

1.1内核

docker官方说至少3.8以上,建议3.10以上(ubuntu下要linux内核3.8以上, RHEL/Centos 的内核修补过,centos6.5的版本就可以——这个可以试试)

uname -a

 

1.2卸载旧版本

检查是否已安装过docker

yum list installed |grep docker

卸载旧版本

yum remove docker docker-client docker-client-latest \

docker-common docker-latest docker-latest-logrotate \

docker-logrotate docker-engine

2.安装

2.1在线安装

安装docker仓库需要的依赖程序。

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

设置docker仓库

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

安装最新版docker

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

2.2离线安装

A.安装包地址:

https://download.docker.com/linux/static/stable/x86_64/

csdn下载地址(上面下载很慢,可以使用这个)

http://download.youkuaiyun.com/download/leadseczgw01/12043473

官方文档:

https://docs.docker.com/install/linux/docker-ce/binaries/#install-static-binaries

B.解压文件并移动

tar xvf docker-19.03.5.tgz

将解压出来的docker文件内容移动到 /usr/bin/ 目录下

cp docker/* /usr/bin/

c.将docker注册为service

vim /etc/systemd/system/docker.service

将下列配置加到docker.service中并保存

[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

[Service]

Type=notify

# the default is not to use systemd for cgroups because the delegate issues still

# exists and systemd currently does not support the cgroup feature set required

# for containers run by docker

ExecStart=/usr/bin/dockerd

ExecReload=/bin/kill -s HUP $MAINPID

# Having non-zero Limit*s causes performance problems due to accounting overhead

# in the kernel. We recommend using cgroups to do container-local accounting.

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

# Uncomment TasksMax if your systemd version supports it.

# Only systemd 226 and above support this version.

#TasksMax=infinity

TimeoutStartSec=0

# set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

# kill only the docker process, not all processes in the cgroup

KillMode=process

# restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s



[Install]

WantedBy=multi-user.target

D.添加文件权限并启动docker

chmod +x /etc/systemd/system/docker.service

重载unit配置文件

systemctl daemon-reload

启动Docker

systemctl start docker

设置开机自启

systemctl enable docker.service

2.3镜像加速

对于使用 systemd 的系统(Ubuntu 16.04+、Debian 8+、CentOS 7), 在配置文件 /etc/docker/daemon.json 中加入:

{
  "registry-mirrors": [
        "https://dockerhub.azk8s.cn",
        "https://reg-mirror.qiniu.com/",
        "https://docker.mirrors.ustc.edu.cn/"
        ]
}

然后重新启动Docker服务

sudo systemctl daemon-reload

sudo systemctl restart docker

参考文档:

http://mirrors.ustc.edu.cn/help/dockerhub.html?highlight=docker

3.运行

sudo systemctl start docker

测试

sudo docker run hello-world

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kenick

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值