1.下载二进制包
尽量使用较新的版本V19|20
https://download.docker.com/linux/static/stable/x86_64/
2. 解压
tar -xvf docker-19.03.9.tgz
sudo mv ./docker/* /usr/bin
3. 编辑service文件
sudo vim /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
增加执行权限
sudo chmod +x /etc/systemd/system/docker.service
开机启动
sudo systemctl enable docker.service
4. 启动&配置
sudo systemctl start docker
sudo docker ps
免sudo权限
// 添加组
sudo groupadd docker
//加入组
sudo gpasswd -a ${USER} docker
//重启docker
sudo systemctl restart docker
//打开新会话
sudo newgrp - docker
配置镜像加速,地址去阿里云拿
sudo vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"],
"log-opts": {
"max-size": "20m",
"max-file": "5"
}
}