其它版本linux内核系统或许略有不同
下载docker版本包
https://download.docker.com/linux/static/stable/x86_64/
centos部署版本
上传到服务器目录下,解压文件。
tar -xvf docker-XXXXXX.tgz
将解压出来的docker文件内容移动到 /usr/bin/ 目录下,该命令使用sudo进行,否则可能会出现权限不足的问题。
sudo cp docker/* /usr/bin/
将docker注册为service服务,使用vim命令新建该文件。
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
添加文件权限并启动docker 。
chmod +x /etc/systemd/system/docker.servicesystemctl daemon-reload
systemctl start docker #启动Docker
systemctl enable docker.service #设置开机自启
centos升级docker版本
停止docker服务
systemctl stop docker.service
上传到服务器目录下,解压文件 (以23版本为例)。
tar -xvf docker-23.0.4.tgz
将解压出来的docker文件内容移动到 /usr/bin/ 目录下,该命令使用sudo进行,否则可能会出现权限不足的问题。
sudo cp docker/* /usr/bin/
重新启动Docker服务
systemctl daemon-reload
systemctl start docker #启动Docker
请注意,在进行任何升级操作之前,务必备份您的数据,并在生产环境之前进行测试。
ubuntu离线安装docker
cat /etc/lsb-release输出:disTRIB_ID=UbuntudisTRIB_RELEASE=22.04disTRIB_CODENAME=jammy // 非常重要,下面选择包的时候需要disTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"
确定dpkg的版本
sudo dpkg --print-architecture输出:
amd64
包下载地址:
https://download.docker.com/linux/ubuntu/dists/jammy/pool/stable
包下载:
containerd.io_1.6.8-1_amd64.deb
docker-ce_20.10.13~3-0~ubuntu-jammy_amd64.deb
docker-ce-cli_20.10.13~3-0~ubuntu-jammy_amd64.deb
安装:
sudo dpkg -i *.deb && apt-get -f install
启动docker
systemctl start docker
查看详情:
docker info