【发布时间】:2021-12-01 20:02:06
【问题描述】:
当我尝试使用 docker 连接到 mysql 时遇到问题。
我的 docker-compose 文件
version: '2'
services:
app:
build:
context: ./docker/app
dockerfile: Dockerfile
image: ebdaa-m.test.com/app
volumes:
- .:/var/www/html
ports:
- "80:80"
networks:
- sdnet
node:
build:
context: ./docker/node
dockerfile: Dockerfile
image: ebdaa-m.test.com/node
volumes:
- .:/var/www/html
networks:
- sdnet
mysql:
image: mariadb:10.5
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "ecom"
MYSQL_USER: "root"
MYSQL_PASSWORD: "root"
volumes:
- mysqldata:/var/lib/mysql
networks:
- sdnet
redis:
image: redis:alpine
volumes:
- redisdata:/data
networks:
- sdnet
networks:
sdnet:
driver: "bridge"
volumes:
mysqldata:
driver: "local"
redisdata:
driver: "local"
现在,当我编写这个容器时,容器就被创建了。我的 docker ps -a 命令给了我以下结果
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5c925d3610c0 ebdaa-m.test.com/node "node" 2 minutes ago Exited (0) 2 minutes ago ebdaa-m-node-1
d001ed99afa4 mariadb:10.5 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:3306->3306/tcp ebdaa-m-mysql-1
7f86bd9a006c ebdaa-m.test.com/app "/usr/bin/supervisord" 2 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp ebdaa-m-app-1
354b5ae00e39 redis:alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp ebdaa-m-redis-1
现在当我尝试使用 sequel pro 连接到 mysql 时。我正在传递以下凭据进行连接
Host: 127.0.0.1
User: root
Password: root
Port: 3306
尝试建立连接时出现以下错误-:
Lost connection to MySQL server at 'reading initial communication packet', system error: 0 (2013)
Double-check the MySQL host and port settings are correct, the server is running, and that no firewall settings are blocking access to the server.
If you are connecting through an SSH tunnel, the MySQL host should be the correct address relative to the machine you're SSHing into. Using, for example, the external IP for the MySQL host rather than the local one can often be a source of problems.
请帮忙。我无法理解可能是什么问题,因为它之前运行良好。
提前谢谢你。
【问题讨论】:
标签: mysql laravel docker docker-compose mariadb