在线安装: 官方文档
离线安装: 官方文档
下载指定版本二进制离线包:https://download.docker.com/linux/static/stable/
# 例
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.19.tgz
解压二进制压缩包
tar -zxvf docker-20.10.19.tgz
配置Docker用户
# 创建组
groupadd docker
# 添加Docker用户
useradd -g docker docker
# 设置密码
passwd docke
# 添加sudo权限:docker ALL=(ALL) ALL,增加一行
sudo visudo
将二进制文件移动到可执行文件目录
sudo cp docker/* /usr/bin/
注册systemctl自启
通过yum、apt-get安装,在启动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
增加执行权限
chmod +x /etc/systemd/system/docker.service
加载配置
systemctl daemon-reload
启动Docker
systemctl start docker
# 查看状态
systemctl status docker
配置开机自启
systemctl enable docker.service
systemctl is-enabled docker.service
下载可执行文件:
# 更多版本参见:https://github.com/docker/compose/releases
wget https://github.com/docker/compose/releases/download/v2.24.2/docker-compose-linux-x86_64
移动到可执行文件目录
cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose
添加可执行权限
chmod +x /usr/local/bin/docker-compose
验证是否可用
docker-compose -v
安装wsl_update后重启电脑