【简答题】
按下列要求完成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=%257B%2522request%255Fid%2522%253A%2522168994567316782427435997%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168994567316782427435997&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-20-124924233-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