17
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

dockerでWordPressをサクッと起動

Last updated at Posted at 2018-01-04
# WordPress単体のコンテナを起動
$ docker run --detach --publish 9000:80 wordpress

http://localhost:9000/ にアクセスすると初期設定画面になる。

Screen Shot 2018-01-04 at 13.25.04.png

ただ、DBは別で設定しないといけないのでこれだけでは、設定完了までいくことはできない。

docker-composeでDB環境もまとめて用意

せっかくなのでDBもdockerで用意する。
複数のコンテナをまとめて設定/構築するなら docker-compose が有効。

必要なファイルはdocker-compose.ymlだけ。

docker-compose.yml
version: "3.5"

services:
  wordpress:
    image: wordpress:latest
    ports:
      - 9000:80
    links:
      - wordpress-db
    environment:
      WORDPRESS_DB_HOST: wordpress-db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wp_user
      WORDPRESS_DB_PASSWORD: database_password

  wordpress-db:
    image: mysql:5.7
    ports:
      - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: database_password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wp_user
      MYSQL_PASSWORD: database_password

あとは以下のコマンドでコンテナを作って起動。

# 起動コマンド
$ docker-compose up --detach

# 起動中のコンテナを確認
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
4b5e916f0b7a        wordpress:latest    "docker-entrypoint..."   22 minutes ago      Up 22 minutes       0.0.0.0:9000->80/tcp   dockerwordpress_wordpress_1
72b22f911f86        mysql:latest        "docker-entrypoint..."   22 minutes ago      Up 22 minutes       3306/tcp               dockerwordpress_db_1

wordpressとmysqlが起動していることがわかる。

http://localhost:9000/ にアクセスすると初期設定画面になるので設定を進めていけばWordPressが使えるようになる。

Screen Shot 2018-01-04 at 13.25.04.png

Screen Shot 2018-01-04 at 13.57.54.png

Screen Shot 2018-01-04 at 13.58.00.png

Screen Shot 2018-01-04 at 13.58.19.png

Screen Shot 2018-01-04 at 13.58.29.png

Screen Shot 2018-01-04 at 13.58.40.png

いい感じ

17
25
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?