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.csdn.net/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

你可能感兴趣的:(工具,docker,安装,离线)