离线安装
下载下面链接的包ubuntu安装
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.4.12_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.12_amd64.deb
wget https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce_20.10.12_amd64.deb
安装依赖项和docker
sudo dpkg -i containerd.io_1.4.12_amd64.deb
sudo dpkg -i docker-ce-cli_20.10.12_amd64.deb
sudo dpkg -i docker-ce_20.10.12_amd64.deb
启动docker
sudo systemctl start docker
开机自启docker
sudo systemctl enable docker
查看docker版本
sudo docker --version
<<centos7 安装 docker >>
tar -zvxf docker-24.0.7.tgz
chmod 775 docker/*
拷贝文件到 cp docker/* /usr/bin
cd /etc/systemd/system/ 目录下新建 docker.service 文件 命令 touch docker.service
编辑 vim /etc/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target
Wants=network-online.target containerd.service
[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
TimeoutStartSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# 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
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# 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
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
添加文件夹权限
chmod u+x /etc/systemd/system/docker.service
新建 daemon.jons文件
新建文件夹
mkdir /etc/docker
在文件夹里面 新建文件 touch daemon.json
编辑文件 vim /ect/docker/daemon.json
添加下列json串
{"registry-mirrors":[
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"]
}
{"registry-mirrors": ["https://gfmnzvu1.mirror.aliyuncs.com"]}
保存 wq!
重载 unit
systemctl daemon-reload
启动 systemctl start docker
查看状态 systemctl status docker