8
10

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の使い方メモ

Posted at

KitematicでWordPressとmysqlのコンテナをさくっと作れると思ったけど、以下の様なMySQL Connection Errorが出て使えなかったので、代わりにDocker Composeを使用。

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 10
Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 10
MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known

Docker Composeインストール

curl -L https://github.com/docker/compose/releases/download/1.3.2/docker-compose-`uname -s`-`uname -m` > docker-compose
sudo cp docker-compose /usr/local/bin/
sudo chmod +x /usr/local/bin/docker-compose

ymlファイル作成

作成したファイルは、WrodPressのローカルファイルを置きたいところ同じディレクトリに置けばOK。

docker-compose.yml
wordpress:
  image: wordpress:latest
  volumes:
    - src:/var/www/html
  links:
    - db:mysql
  ports:
    - 80:80
  environment:
    WORDPRESS_DB_PASSWORD: password
db:
  image: mysql:latest
  environment:
    MYSQL_ROOT_PASSWORD: password

Docker Composeの実行

docker-compose.ymlを置いたディレクトリで以下のコマンドを実行。

docker-compose up

WORDPRESS_DB_HOSTの設定

KitematicのWordpressのコンテナの設定のEnvironment Variablesで以下を追加。

WORDPRESS_DB_HOST: [mysqlのコンテナ名]
8
10
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
8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?