1
3

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-composeで一瞬でwordpress環境を作る

1
Last updated at Posted at 2017-12-14

久しぶりにwordpressのローカル環境作ることがあって、過去にdocker-composeでつくったやつがあったのを思い出したのでメモ

作成したdocker-composeはgithubに上げてあります
https://github.com/megaya/docker_compose_for_wordpress

フロントの人がいじりやすいように、クライアントにあるファイルをいじれるようにしたいので./wordpressディレクトリをマウントするようにしました

環境

今のところmacでしか試していませんが、どこでも動くと思います

  • docker
  • docker native(if mac or win)
  • docker-compose

使い方

$ git clone https://github.com/megaya/docker_compose_for_wordpress
$ ./init.sh

# or

$ ./init.sh 3.4.1

cloneしたあとに./init.shを叩くようにしてください。

シェルが使える環境であれば、./init.shを叩けばwordpressを自動で落とせます
現状では4.5.2がダウンロードされます
他のバージョンが良い方は、引数にバージョンを指定してください

これを叩くと./misc/datastoreというディレクトリが作成されます。そこをホストのvolumesにしています。

$ docker-compose up

docker nativeであれば以下で開くと思います
違う場合はipを指定してください

ほんの少しの解説

docker-composeに落とし込んだだけなので、ほぼありません
公式を見ればほぼのってます

dockerhub
https://hub.docker.com/_/wordpress/

github
https://github.com/docker-library/wordpress/tree/61dd78ce4fa9ccd592ead1edb379f209533b850c

パスやホストの指定など

公式のDockerfileで下記のように、wp-config.phpがないときは作成してくれるようです

if [ ! -e wp-config.php ]; then
	 wp-config-sample.php > wp-config.php

それと環境変数のpasswordなどで、wp-config.phpを書き換えてくれる

set_config 'DB_HOST' "$WORDPRESS_DB_HOST"

参考

公式dokcerhub
https://hub.docker.com/_/wordpress/

公式github
https://github.com/docker-library/wordpress

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?