docker-compose 综合训练

题目要求

按下列要求完成docker-compose.yml的编写,将yml复制到答题区

1)服务:db

镜像:mysql:5.7

卷:db_data:/var/lib/mysql

定义容器重启策略

环境变量

root密码:somewordpress

数据库:wordpress

用户:wordpress

密码:wordpress

2)服务:wordpress

在数据库之后启动

镜像:wordpress:latest

端口映射:8080:80

定义容器重启策略

环境变量

WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress

卷:

db_data:{}

version: "3.5" services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8080:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_NAME: wordpress volumes: db_data: {} 

启动docker-compose

docker-compose up -d

测试网页

docker-compose 综合训练插图

docker-compose 综合训练插图1 查看项目容器

docker-compose ps

docker-compose 综合训练插图2

查看项目镜像

docker-compose 综合训练插图3

查看项目的网络和卷

docker-compose 综合训练插图4

原文链接:https://blog.csdn.net/weixin_62816287/article/details/124924223?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168994567416800192286954%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168994567416800192286954&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-4-124924223-null-null.268%5Ev1%5Ekoosearch&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享