【简答题】
按下列要求完成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:{}
创建文件夹
mkdir wordpress1
进入文件夹
cd wordpress1
创建并编辑文件夹
vim docker-compose.yml
编辑内容
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 up -d
在浏览器输入ip加8080端口 比如:192.168.163.12:8080
查看容器
docker-compose ps
查看镜像
docker-compose images
查看卷
docker volume ls
查看网络
docker network ls
原文链接:https://blog.csdn.net/qq_53235556/article/details/124924233?ops_request_misc=&request_id=3644b30f52c14f5aaeffe50e7c8950c8&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-1-124924233-null-null.268%5Ev1%5Econtrol&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