DockerでWordPressを手軽に動かす

WordPressを自分のPC上で動かします。Dockerを使えば簡単に起動できますので、手順を簡単に記載します。(Dockerはインストールしてある前提です)

docker-compose.ymlファイルの作成

下記の内容で任意のフォルダ内に、docker-compose.ymlを作成します。dockerHubの内容を参考にしています。

version: '3.1'

services:
  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress_data:/var/www/html

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db_data:/var/lib/mysql

volumes:
  wordpress_data:
  db_data:

コンテナの起動

docker-compose up -d
[+] Running 34/34
 ✔ wordpress 21 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled         134.2s 
   ✔ 9e3ea8720c6d Pull complete          14.1s 
   ✔ 07353b772b5e Pull complete         14.3s 
   ✔ 5908153120ba Pull complete         81.3s 
   ✔ 8681ad2eeea6 Pull complete          82.1s 
   ✔ 92711ce78973 Pull complete         88.3s 
   ✔ bf1c5be6427e Pull complete           89.0s 
   ✔ 1d02a81768ed Pull complete          96.4s 
   ✔ d674a0135f85 Pull complete          97.5s 
   ✔ 6d87d0359817 Pull complete         98.0s 
   ✔ 5e8c2df9b69e Pull complete           103.8s 
   ✔ aacfb138e3c1 Pull complete           104.5s 
   ✔ 2db2528ade33 Pull complete         105.0s 
   ✔ beeef66f0c04 Pull complete           106.1s 
   ✔ f06b38c16403 Pull complete         111.1s 
   ✔ a2c661d6acd5 Pull complete         113.3s 
   ✔ e4ac8d746152 Pull complete        113.6s 
   ✔ f264881ab77b Pull complete        114.5s 
   ✔ 0436c0c6e94a Pull complete        114.7s 
   ✔ c8e79477b493 Pull complete        126.0s 
   ✔ 4b03195a981c Pull complete        126.6s 
   ✔ faf6b8f25923 Pull complete          128.4s 
 ✔ db 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled         114.5s 
   ✔ e83e8f2e82cc Pull complete         32.4s 
   ✔ 0f23deb01b84 Pull complete        32.6s 
   ✔ f5bda3b184ea Pull complete        32.8s 
   ✔ ed17edbc6604 Pull complete        33.2s 
   ✔ 33a94a6acfa7 Pull complete         33.3s 
   ✔ f153bd2953e4 Pull complete        33.5s 
   ✔ ab532edfb813 Pull complete        35.2s 
   ✔ c76bdfe4f3d0 Pull complete         35.5s 
   ✔ 8a7ffe2f2551 Pull complete         109.1s 
   ✔ 857ada4fbbcc Pull complete        109.4s 
   ✔ b7c508404c3c Pull complete      109.7s 
[+] Running 5/5
 ✔ Network wordpress_default          Created            1.7s 
 ✔ Volume "wordpress_wordpress_data"  Created   0.1s 
 ✔ Volume "wordpress_db_data"         Created         0.1s 
 ✔ Container wordpress-wordpress-1    Started        26.2s 
 ✔ Container wordpress-db-1           Started

ブラウザで確認する

http://localhost:8080/にアクセスします。

ここから各種設定に進み、利用開始できます。

[Sponsored Links]







  • このエントリーをはてなブックマークに追加
[Sponsored Links]