聊聊其他之ShowDoc安装部署
Docker离线安装部署
由于很多公司服务器处于内网环境,跟外网阻断,所以需要通过离线的方式进行Docker镜像安装。
Linux环境准备
第一步:检查防火墙,是否关闭。
查看防火墙状态:
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)防火墙关闭
[root@localhost ~]# systemctl stop firewalld
第二步:关闭Selinux策略
将配置文件中的SELINUX改成disabled后保存退出
[root@localhost ~]# vi /etc/selinux/config
SELINUX=disabled
第三步:检查文件/etc/timezone
检查是否存在/etc/timezone 文件,如果没有,后面执行docker run 命令的时候,需要删除命令中关>于/etc/timezone 的映射以免报错,只是用/etc/localtime做时间同步
前期准备工作完成
Docker部署
第一步:下载安装包。
下载安装包路径:https://download.docker.com/linux/static/stable/x86_64/
第二步:上传至服务器
[root@localhost docker]# pwd
/ftp/Stability/docker[root@localhost docker]# ll
total 61772
-rw-r--r-- 1 root root 63252595 Jan 7 09:55 docker-19.03.5.tgz
第三步:解压程序包
[root@localhost docker]# tar -zxvf docker-19.03.5.tgz
docker/
docker/docker-init
docker/docker
docker/dockerd
docker/runc
docker/ctr
docker/docker-proxy
docker/containerd
docker/containerd-shim
第四步:拷贝程序
.[root@localhost docker]# sudo cp docker/* /usr/bin/
第五步:程序运行,后台启动
[root@localhost docker]# sudo dockerd &
第六步:设置docker开机启动,务必关闭selinux,并且重启了系统。
总共包含两个文件:
docker.service和docker.sockert
其中docker.service内容如下
[root@localhost docker]# cat 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.socket内容如下
[root@localhost docker]# cat docker.socket
[Unit]
Description=Docker Socket for the API
PartOf=docker.service
[Socket]
# If /var/run is not implemented as a symlink to /run, you may need to
# specify ListenStream=/var/run/docker.sock instead.
ListenStream=/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target
第七步:执行命令,设置docker开机自启动;在docker.service和docker.socket所在文件夹行进行执行。
[root@localhost docker]# sudo cp docker.socket /etc/systemd/system
[root@localhost docker]# sudo cp docker.service /etc/systemd/system
[root@localhost docker]# sudo systemctl daemon-reload
[root@localhost docker]# sudo systemctl start docker
[root@localhost docker]# sudo systemctl enable docker
设置完以后使用reboot重启服务器,docker会开机自启动
检查docker服务是否启动
[root@localhost docker]# sudo systemctl status docker
● docker.service - Docker Application Container EngineLoaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)Active: active (running) since Fri 2022-01-07 10:11:54 CST; 45s ago
至此docker服务已经安装完成
ShowDoc安装
第一步:下载ShowDoc镜像文件
由于很多公司网络限制,需要本地进行安装
第二步:加载镜像
[root@localhost showdoc]# docker load –i images.tar
第三步:工作准备
[root@localhost showdoc]# sudo mkdir /data
[root@localhost showdoc]# sudo mkdir /data/showdoc_data
[root@localhost showdoc]# sudo mkdir /data/showdoc_data/html
[root@localhost showdoc]# sudo chmod –R 777 /data/showdoc_data
第四步:运行镜像
[root@localhost showdoc]# docker run –d –name showdoc –p 4999:80 –v /data/showdoc_data/html:var/www/html/star7th/showdoc
第五步:平台访问,地址:http://XX.XX.XX.XX:4999/