Docker组合端口3306上的mysql可达

时间:2016-01-21 14:16:51

标签: mysql docker docker-compose

如何使这个docker-compose中的mysql数据库可以从"外部" - 这意味着我可以连接数据库管理工具,例如在端口3306上:

wordpress:
 build: /Users/FabianL/wp-docker/
 container_name: "kr-wp-container"
 links:
   - db:mysql
 ports:
   - 8080:80
   - 3306:3306
db:
 image: mysql
 environment:
   MYSQL_ROOT_PASSWORD: biersaufen

1 个答案:

答案 0 :(得分:4)

您已从容器“wordpress”打开端口8080和3306,而未从容器“db”打开端口

将撰写文件更改为:

wordpress:
 build: /Users/FabianL/wp-docker/
 container_name: "kr-wp-container"
 links:
   - db:mysql
 ports:
   - 8080:80
db:
 image: mysql
 environment:
   MYSQL_ROOT_PASSWORD: biersaufen
 ports:
   - 3306:3306