二进制下载
Docker
https://download.docker.com/linux/static/stable/x86_64/
Docker Compose
https://github.com/docker/compose/releases
解压安装
安装
下载得到 docker-27.2.1.tgz
和 docker-compose-linux-x86_64
两个文件。
# 解压 docker
tar -vxzf docker-27.2.1.tgz
# 拷贝到系统 PATH 下
cp -f docker/* /usr/bin/
# 创建 docker plugins 目录,用于放置 docker compose
mkdir -p /usr/lib/docker/cli-plugins
# 拷贝 docker compose 到目录下
mv docker-compose-linux-x86_64 /usr/lib/docker/cli-plugins/docker-compose
# 添加可执行权限
chmod +x /usr/lib/docker/cli-plugins/docker-compose
# 刷新
source ~/.bashrc
设置为系统服务
创建一个 docker.service
的系统服务,并设置开机自启。
# 创建一个 docker.service
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 --selinux-enabled=false
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
刷新、启动并设置开机自启:
# 刷新
systemctl daemon-reload
# 启动
systemctl start docker.service
# 查看状态
systemctl status docker.service
# 设置开机自启
systemctl enable docker.service