WordPress on Docker

首先,创建配置文件 composer-compose.yml。

version: '3.3'

services:

  nginx:
    image: nginx
    restart: always
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./:/var/www/html
    ports:
      - 80:80

  wordpress:
    image: wordpress:php7.2-fpm
    restart: always
    volumes:
      - ./:/var/www/html
    environment:
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: wordpress

  mysql:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: wordpress

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

启动容器:执行如下命令自动下载需要的 Docker 镜像,然后启动容器。

docker-composer up -d

关闭容器:执行如下命令会首先关闭容器,然后移除容器和默认网络,但是不会清空数据库。

docker-composer down

参考:

https://docs.docker.com/compose/wordpress/
https://hub.docker.com/_/wordpress/
https://hub.docker.com/_/mysql/
https://hub.docker.com/_/nginx/

 758 total views,  3 views today

Leave a Reply

Your email address will not be published. Required fields are marked *