Docker安装教程
下载安装包
https://mirrors.aliyun.com/docker-ce/
二进制包:https://mirrors.aliyun.com/docker-ce/linux/static/stable/x86_64/docker-20.10.21.tgz
安装
tar -xvf docker-20.10.21.tgz
mv docker/* /usr/local/bin
Systemd管理服务
vim /lib/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/local/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 gpasswd -a $USER docker
sudo newgrp docker
Docker启停
加载systemd服务文件:systemctl daemon-reload
启动:systemctl start docker
停止:systemctl stop docker
重新加载docker配置文件:systemctl reload docker
开机默认启动:systemctl enable docker
开机默认停止:systemctl disable docker
检查Docker是否可用
查看版本:docker version
查看详情:docker info
优化Docker
添加Docker镜像加速器
{
"registry-mirrors": ["https://sh8bijia.mirror.aliyuncs.com"]
}
修改镜像存储地址:
{
"data-root": "/www/docker"
}