执行命令,查看linux的系统内核,并且根据linux内核下载对应版本docker 安装包
uname -r
官方下载linux
官方其他版本
查看是否安装docker
yum list installed | grep docker
安装docker
yum -y install docker
先下载对应安装包,解压
tar -zxvf docker-20.10.19.tgz
将解压内容复制到/usr/bin
cp docker/* /usr/bin
在/usr/lib/systemd/system
目录下新增docker.service
文件,并建立软连接,内容如下,注意:insecure-registry
要改成自己的ip
建立连接
ln -s '/usr/lib/systemd/system/docker.service' '/etc/systemd/system/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
这个是正常linux的文件内容
[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 --selinux-enabled=false --insecure-registry=127.0.0.1
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
给docker.service
添加权限
chmod a+x /etc/systemd/system/docker.service
重新加载配置文件
systemctl daemon-reload
启动/重启/查看状态
systemctl start/stop/restart/status docker
设置开机启动
systemctl enable docker.service
vi /etc/docker/daemon.json
# 下面是镜像地址,配置这个,加快下载速度
{"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn"]
}