赞
踩
本文只适用X86架构的麒麟操作系统。
由于麒麟操作系统的内核使用的是CentOS 8 ,我们只需下载适用CentOS系统的Docker版本。
1. 从官方下载Docker安装包并上传到服务器
https://download.docker.com/linux/static/stable/x86_64/
2. 解压安装包
tar -xvf docker-19.03.9.tgz
3. 将解压出来的docker文件内容移动到 /usr/bin/ 目录下
#移动命令 复制命令请用cp
mv docker/* /usr/bin/
4. 将docker注册为service服务
vi /etc/systemd/system/docker.service
5. 配置全局参数
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://06us4gvd.mirrors.aliyuncs.com"],
"log-driver":"json-file",
"log-opts": {"max-size":"500m", "max-file":"3"}
}
EOF
6. 配置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
7. 启动docker
chmod +x /etc/systemd/system/docker.service #设置权限
systemctl daemon-reload
systemctl start docker #启动Docker
systemctl enable docker.service #设置开机自启
8. 验证
systemctl status docker #查看Docker状态
docker -v #查看Docker版本
9. 将制作好的镜像上传到服务器
10. 加载相关镜像
#!/bin/sh #安装mysql镜像 docker load -i /soft/images/mysql5.7.tar #安装ftp镜像 docker load -i /soft/images/ftp.tar #安装open-office镜像 docker load -i /soft/images/open-office.tar #安装xxl-job镜像 docker load -i /soft/images/xxl-job.tar #安装tomcat镜像 docker load -i /soft/images/tomcat8.5.7.tar #安装考试系统tomcat镜像 docker load -i /soft/images/exam.tar #安装Adminer镜像 docker load -i /soft/images/adminer.tar #查看安装镜像列表 docker images
11. 启动tomcat服务
docker run --name $CONTAINER -p $PORT:8080 -v /ReachData/$CONTAINER/web:/usr/local/docker/apache-tomcat-8.5.77/webapps -v /ReachData/$CONTAINER/logs:/usr/local/docker/apache-tomcat-8.5.77/logs -v /ReachData/$CONTAINER/file/RecData:/RecData -v /ReachData/$CONTAINER/conf/server.xml:/usr/local/docker/apache-tomcat-8.5.77/conf/server.xml --restart=always -v /etc/localtime:/etc/localtime:ro --link mysql:mysql --link open-office:open-office -d f780b6663e72
系统启动后报错,使用 docker logs 命令查看日志
library initialization failed - unable to allocate file descriptor table - out of memoryAborted (core dumped)
解决方案:在执行 docker run 命令时添加参数 --ulimit nofile=65535:65535 --ulimit nproc=65535:65535 --privileged=true
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。