1. tgz安装:
参考:Linux离线环境安装部署docker(超详细)_linux离线安装docker_苏晗兮的博客-CSDN博客
**更简单安装(可以忽略tgz安装的其他内容):麒麟v10操作系统 安装docker_kylin安装docker_大白守护进程的博客-CSDN博客
docker-Linux下载地址:Index of linux/static/stable/x86_64/ (docker.com)
- 解压docker软件压缩包
tar -zxvf docker-20.10.9.tgz
- 把docker文件里面的内容复制到bin目录下
cp docker/* /usr/bin
- 在/etc/systemd/system或者/usr/lib/systemd/system目录下创建文件 docker.socket和docker.service以及containerd.service
- 三个文件的内容放最后面,记得先把文件内容加上才能启动docker哦
touch docker.socket
touch docker.service
touch containerd.service
- 启动(需要完成步骤3的文件内容!!!):
systemctl start docker
docker ps
systemctl enable docker.service
- 内容:
docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.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
#ExecStart=/usr/bin/docker daemon --tlsverify --tlscacert=/root/openssl/ca.pem --tlscert=/root/openssl/server-cert.pem --tlskey=/root/openssl/server-key.pem --registry-mirror=http://3cda3ca9.m.daocloud.io -H tcp://0.0.0.0:2376
#ExecStart=/usr/bin/docker daemon --registry-mirror=http://3cda3ca9.m.daocloud.io -H fd:// -H tcp://0.0.0.0:2375
#ExecStart=/usr/bin/dockerd --registry-mirror=http://3cda3ca9.m.daocloud.io
ExecStart=/usr/bin/dockerd --registry-mirror=http://3cda3ca9.m.daocloud.io -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
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
[Install]
WantedBy=multi-user.target
containerd.service
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=infinity
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
2. rpm安装(目前不推荐了):
一、下载地址:
docker相关https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
container-selinux相关http://rpmfind.net/linux/centos/7/extras/x86_64/Packages/
依赖包相关http://mirrors.163.com/centos/7/os/x86_64/Packages/
二、依赖包安装(依赖情况可能各不相同,根据提示下载安装)
安装顺序:dep1->dep>docker_rpm
按顺序执行
sudo rpm -ivh --force *.rpm --force
之后执行
sudo rpm -ivh container-selinux-2.107-1.el7_6.noarch.rpm --force
sudo rpm -ivh docker-ce-19.03.3-3.el7.x86_64.rpm --force
启动
sudo service docker start
dep1:
audit-libs-2.8.5-4.el7.x86_64.rpm
libsepol-2.5-10.el7.x86_64.rpm
libselinux-2.5-15.el7.x86_64.rpm
policycoreutils-2.5-34.el7.x86_64.rpm
libselinux-utils-2.5-15.el7.x86_64.rpm
selinux-policy-3.13.1-268.el7.noarch.rpm
libsemanage-2.5-14.el7.x86_64.rpm
selinux-policy-targeted-3.13.1-268.el7.noarch.rpm
dep:
audit-libs-python-2.8.5-4.el7.x86_64.rpm
libseccomp-2.3.1-4.el7.x86_64.rpm
checkpolicy-2.5-8.el7.x86_64.rpm
libsemanage-python-2.5-14.el7.x86_64.rpm
container-selinux-2.107-1.el7_6.noarch.rpm
containerd.io-1.4.6-3.1.el7.x86_64.rpm
policycoreutils-python-2.5-34.el7.x86_64.rpm
python-IPy-0.75-6.el7.noarch.rpm
docker-ce-cli-19.03.3-3.el7.x86_64.rpm
setools-libs-3.3.8-4.el7.x86_64.rpm
libcgroup-0.41-21.el7.x86_64.rpm
docker_rpm:
docker-ce-19.03.3-3.el7.x86_64.rpm