系统综合实践 第3次实践作业

一.安装docker-compose
1.下载docke-compose

2.添加可执行权限

3.测试安装结果

二.拉取相关镜像
1.mysql

2.php

3.nginx

三.编写dockerfile(创建docker_compose文件夹,并建立web文件夹作为nginx,php的工作目录和挂载容器卷的目录,建立mysql_data作为mysql挂载容器卷的目录)
1.dockerfile_mysql

2.dockerfile_php

3.dockerfile_nginx

4.default.conf

5.docker-compose.yml

6.在web目录中建立index.html文件,index.php文件

四.使用compose实现多容器运行机制
1.查看docker_compose的树状结构

2.执行docker-compose

3.查看镜像

4.查看容器

5.访问localhost/index.html

6.访问localhost/index.php

五.服务测试
1.检测PHP是否能够成功连接Mysql数据库
(1)修改index.php文件

(2)访问ocalhost/index.php

2.在index.php文件中创建数据库
(1)修改index.php文件

(2)访问ocalhost/index.php

(3)进入mysql容器,进入数据库并查询数据库

3.在数据库中创建数据表
(1)创建user数据表

(2)访问http://localhost/index.php

(3)在mysql容器中,选中数据库并查询数据表

4.向user数据表中插入数据
(1)插入数据

(2)访问http://localhost/index.php

(3)在数据库中查询

5.修改user数据
(1)修改数据

(2)访问http://localhost/index.php

(3)在数据库中查询记录是否被修改

6.删除表中数据
(1)删除数据

(2)访问http://localhost/index.php

(3)在数据库中查询记录是否被删除

六。增加phpmyadmin容器,实现web端的数据库管理
1.在docker-compose.yml文件中增加以下代码

2.在docker_compose文件夹中创建并编写docker_phpmyadmin文件

3.访问localhost:8080/index.php

原文地址:https://www.cnblogs.com/silentstone/p/12845410.html