当前位置: 首页 > news >正文

线上考试系统---虚拟化技术部署

部署前端服务器

1.将资源上传到服务器

scp -r dist/ root@192.168.1.50:~

2.在服务器上创建基础容器

[root@docker0 ~]# docker run -it --name c0 centos:latest /bin/bash
[root@c1092b8c9ce5 /]# [root@docker0 ~]# 
[root@docker0 ~]# docker attach c0

3.在容器中修改yum源

[root@c1092b8c9ce5 /]# rm -rf /etc/yum.repos.d/*
[root@c1092b8c9ce5 /]# cat /etc/redhat-release 
CentOS Linux release 8.4.2105
[root@65b0e0641432 /]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  CurrentDload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0   7403      0 --:--:-- --:--:-- --:--:--  7403
[root@65b0e0641432 /]# ls /etc/yum.repos.d/
CentOS-Base.repo
[root@65b0e0641432 /]# yum clean all && yum makecache
Failed to set locale, defaulting to C.UTF-8
0 files removed
Failed to set locale, defaulting to C.UTF-8
CentOS-8.5.2111 - Base - mirrors.aliyun.com       597 kB/s | 4.6 MB     00:07    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com      13 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com  452 kB/s | 8.4 MB     00:19    
Metadata cache created.

4.在容器中安装epel

[root@65b0e0641432 /]# yum -y install epel-release

5.在容器中安装nginx

[root@65b0e0641432 /]# yum -y install nginx
[root@65b0e0641432 /]# [root@docker0 ~]# 

6.导出tar包

[root@docker0 ~]# docker export -o centos_nginx.tar c0
[root@docker0 ~]# ls
anaconda-ks.cfg   centos_nginx.tar  centos_yum.tar  initserver.sh
centos_httpd.tar  centos.tar        dist

7.引入tar包

[root@docker0 ~]# docker import -m "维护世界和平" centos_nginx.tar centos:nginx
sha256:b5d54b55bd165ef173d37d0689512a11747bcf1e478c3b7dfce0f9141c09ba8d

8.查看镜像

[root@docker0 ~]# docker image ls
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
centos       nginx     b5d54b55bd16   10 seconds ago   366MB
mysql        latest    a82a8f162e18   4 weeks ago      586MB
centos       latest    5d0da3dc9764   2 years ago      231MB

9.停用c0容器,删除c0容器

[root@docker0 ~]# docker stop c0
c0
[root@docker0 ~]# docker rm c0
c0
[root@docker0 ~]# docker ps --all
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

10.创建新的centos nginx容器,在创建的同时指定端口,以及 挂载目录

[root@docker0 ~]# docker run -it --name c0 -p80:80/tcp -v /opt/:/usr/share/nginx/html centos:nginx /bin/bash

11.在容器内部启动nginx服务

[root@0a2dcc6f2e1f /]# nginx

12.在宿主上把dist⽬录中的⽂件复制opt⽬录中

[root@docker0 ~]# cp -r dist/* /opt


http://www.mrgr.cn/news/13258.html

相关文章:

  • PHP多门店民宿酒店预订系统小程序源码
  • Linux之ip命令详解
  • qemu:gpio使用
  • 在浏览器输入URL回车之后发生了什么?
  • [Meachines] [Medium] Bastard Drupal 7 Module Services-RCE+MS15-051权限提升
  • 记录|Form1中嵌套Form2时的频闪问题解决[不同于常见的三部曲]
  • 线性二次调节器(LQR)和模型预测控制(MPC)算法对比介绍
  • TCP并发服务端的实现
  • 深度学习学习经验——长短期记忆网络(LSTM)
  • 学术好物!推荐8款写论文神器app查重率低网站
  • 网络通信---三次握手
  • 浅谈【数据结构】链表之单链表
  • 设计模式 9 装饰器模式
  • 【python】Gpt-embedding文本建模
  • 如何使用ssm实现学生就业管理系统
  • 【UE 编译】UE C++工程的编译流程、与C++编译的区别
  • C语言04--数组超详解
  • 如何使用ssm实现开放式教学评价管理系统+vue
  • 【操作系统】实验:指示灯开关控制
  • std::futrue异步操作结果的三种搭配使用