6.19 docker (二)实战WordPresser

WordPress

创建空文件夹

[root@node ~]# mkdir wordpresscd

创建 docker-compose.yml 文件

[root@node ~]# cd wordpress/
[root@node wordpress]# vi docker-compose.yml

version: "3"
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:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes:
  db_data:
文件将开启一个 wordpress 服务和一个独立的 MySQL 实例

构建并运行项目

[root@node wordpress]# docker-compose up -d

 

 




posted @ 2019-06-19 18:26  Guoogle  阅读(140)  评论(0编辑  收藏  举报