0
1

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 3 years have passed since last update.

【docker,PHPでPDO→DB接続】

Posted at

PHPでdockerコンテナ内からPDOで別コンテナにあるDBに接続する方法。
注意点はホスト名をDBのあるコンテナ名にするだけ

userやpasswordはdocker-compose.ymlに従う。

PDO部分

$db = new PDO('mysql:host=docker-practice_mysql_1;dbname=restaurant','root','pass');

コンテナ一覧(terminal)

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
												docker-practice_mysql_1
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?