`
最近开始使用centos 8,发现安装不上docker 18了,发现要docker 19才可以使用, 因为系统是离线的 只能安装离线版的docker,
1.上传安装包
将docker离线包上传到服务器上,可以自定义放的目录。
2.解压安装包
将上传好的安装包解压。
tar -xzvf docker-19.03.6.tgz
3.安装
复制解压后的文件到/usr/bin/,然后执行dockerd &。
cp docker/* /usr/bin/
cp:是否覆盖'/usr/bin/runc'? n
/usr/bin/runc已经有了,可以选择覆盖或不覆盖,都不影响。
执行 dockerd &
4.测试
安装完成后,执行docker info、docker version测试是否安装完成
[root@vm-53-128 software]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.6
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 35bd7a5f69c13e1563af8a93431411cd9ecf5021
runc version:
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.134-13.an8.x86_64
Operating System: Anolis OS 8.8
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 930.8MiB
Name: vm-53-128
ID: GCO5:TTRI:PW3E:35S6:RP5Q:7HSF:7EL7:UXAS:L2B2:FOI6:WBMI:QRKS
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
[root@vm-53-128 software]# docker version
Client: Docker Engine - Community
Version: 19.03.6
API version: 1.40
Go version: go1.12.16
Git commit: 369ce74a3c
Built: Thu Feb 13 01:24:49 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.6
API version: 1.40 (minimum version 1.12)
Go version: go1.12.16
Git commit: 369ce74a3c
Built: Thu Feb 13 01:32:22 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.12
GitCommit: 35bd7a5f69c13e1563af8a93431411cd9ecf5021
runc:
Version: 1.1.3
GitCommit:
docker-init:
Version: 0.18.0
GitCommit: fec3683
[root@vm-53-128 software]#
5.设置docker为系统服务
5.1创建配置containerd服务
在etc目录下创建containerd文件夹,并在containerd文件夹下创建containerd.service文件。相关命令如下:
mkdir /etc/containerd
touch /usr/lib/systemd/system/containerd.service
vim /usr/lib/systemd/system/containerd.service
复制下面的内容到containerd.service中
****[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target
[Service]
ExecStartPre=/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Delegate=yes
KillMode=process
LimitNOFILE=1048576
# 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
[Install]
WantedBy=multi-user.target****
启动containerd服务:
# 重新加载配置信息
systemctl daemon-reload
#设置containerd.service为开机启动
systemctl enable containerd.service
#启动containerd服务
systemctl start containerd.service
#查看containerd服务启动状态
systemctl status containerd.service
5.2创建配置docker.socket服务
在/usr/lib/systemd/system文件夹创建docker.socket文件,命令如下:
touch /usr/lib/systemd/system/docker.socket
vim /usr/lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
# 如果出现错误:chown socket at step GROUP: No such process, 可以修改下面的 SocketGroup=root 或创建 docker 用户组(命令 groupadd docker)
SocketGroup=docker
[Install]
WantedBy=sockets.target
启动containerd服务:
# 重新加载配置信息
systemctl daemon-reload
#设置containerd.service为开机启动
systemctl enable containerd.service
#启动containerd服务
systemctl start containerd.service
#查看containerd服务启动状态
systemctl status containerd.service
5.3创建配置docker.service服务
在/usr/lib/systemd/system文件夹创建docker.service文件:
touch /usr/lib/systemd/system/docker.service
vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[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 -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=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
[Install]
WantedBy=multi-user.target
#解除
systemctl unmask docker.service
systemctl unmask docker.socket
# 重新加载配置信息
systemctl daemon-reload
#设置docker为开机启动
systemctl enable docker
#启动docker服务
systemctl start docker
#查看docker服务启动状态
systemctl status docker