[TOC] > [参考](https://bingohuang.gitbooks.io/docker_practice/content/compose/wordpress.html) ## 注意对 数据库连接的 ip 设置 ``` web: build: . command: php -S 0.0.0.0:8000 -t /code ports: - "8000:8000" links: - db volumes: - .:/code db: image: orchardup/mysql environment: MYSQL_DATABASE: wordpress ``` 数据库的配置指向 db 容器 ``` <?php define('DB_NAME', 'wordpress'); define('DB_USER', 'root'); define('DB_PASSWORD', ''); define('DB_HOST', "db:3306"); define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); ```