一、部署环境
配置名称 | 配置详情 |
---|---|
系统 | CentOS Linux release 7.7.1908 (Core) |
软件名称 | docker |
软件版本 | 20.10.10 |
用户角色 | root |
二、下载安装
1)下载
docker安装包地址:https://download.docker.com/linux/static/stable/x86_64/
大家可以根据自己的需求选择适应的版本,我选择的版本的【20.10.10】
2)安装
- 将安装包文件上传到服务器目录并解压
tar -zxvf docker-20.10.10.tgz
- 将解压出来的docker文件内容移动到 /usr/bin/ 目录下
cp docker/* /usr/bin/
- 将docker注册为service,在/etc/systemd/system目录下创建docker.service文件,并配置如下内容保存
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.service #添加文件权限
systemctl daemon-reload #重载unit配置文件
systemctl start docker #启动Docker
systemctl enable docker.service #设置开机自启
- 验证docker安装是否成功
systemctl status docker #查看Docker状态
docker -v #查看Docker版本
三、离线镜像文件导入
1)docker下载镜像
docker pull zabbix/zabbix-web-nginx-pgsql:alpine-5.0-latest
2)镜像文件导出
镜像导出命令:
docker save [OPTIONS] IMAGE [IMAGE...]
我们可以查看镜像的名称和版本:
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zabbix/zabbix-web-nginx-pgsql alpine-5.0-latest 144a53c4d3f8 4 weeks ago 146MB
所以这里的具体的导出命令是:
docker save -o zabbix-web-nginx-pgsql-5.0.tar zabbix/zabbix-web-nginx-pgsql:alpine-5.0-latest
3)镜像导入
将tar文件上传到内网docker服务器,使用如下命令导入镜像文件:
docker load -i zabbix-web-nginx-pgsql-5.0.tar