Docker安装WordPress博客系统

Docker安装WordPress博客系统

Scroll Down

一、通过docker run方式安装

1.1运行mysql容器

docker run --name mysql -v mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wordpress -d mysql:5.7

1.2运行wordpress

docker run --name wordpress -e WORDPRESS_DB_HOST=mysql:3306 --link mysql -d -p 8080:80 wordpress

二、通过docker-compose方式安装

2.1编写docker-compose.yml文件

version: '3'

services:

  wordpress:
    image: wordpress
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_PASSWORD: root
    networks:
      - my-bridge

  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: wordpress
    volumes:
      - mysql-data:/var/lib/mysql
    networks:
      - my-bridge

volumes:
  mysql-data:

networks:
  my-bridge:
    driver: bridge

2.2运行

docker-compose up -d

2.3浏览器访问进行安装