【问题标题】:Unable to connect to mysql server docker container running in Docker playground无法连接到在 Docker 操场上运行的 mysql 服务器 docker 容器
【发布时间】:2021-07-02 19:59:47
【问题描述】:

我正在https://labs.play-with-docker.com/https://labs.play-with-docker.com/ 的 docker play ground 内运行一个开箱即用的 mysql docker 容器

[node1] (local) root@192.168.0.8 ~
$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED       STATUS       PORTS                               NAMES
f0f8ae352373   mysql     "docker-entrypoint.s…"   2 hours ago   Up 2 hours   0.0.0.0:3306->3306/tcp, 33060/tcp   memories
[node1] (local) root@192.168.0.8 ~
$ 

现在如果我必须从我的本地机器连接到这个 mysql 实例,建议创建一个 SSH 隧道。

这是我尝试过的

➜  sqlconnect ✗ ssh -L 3306:192.168.0.8:3306 ip172-18-0-115-c1mf4d0h550g00dlq95g@direct.labs.play-with-docker.com
Enter passphrase for key '/Users/ankitjha/.ssh/id_rsa':
Connecting to 40.87.120.67:8022
###############################################################
#                          WARNING!!!!                        #
# This is a sandbox environment. Using personal credentials   #
# is HIGHLY! discouraged. Any consequences of doing so are    #
# completely the user's responsibilites.                      #
#                                                             #
# The PWD team.                                               #
###############################################################
[node1] (local) root@192.168.0.8 ~
$

当我尝试从我的 sql dbeaver 客户端连接时

这是我得到的错误

[node1] (local) root@192.168.0.8 ~
$ channel 3: open failed: administratively prohibited: open failed

【问题讨论】:

    标签: docker ssh ssh-tunnel dbeaver


    【解决方案1】:

    你不能这样做。它被设计禁用。检查https://github.com/play-with-docker/play-with-docker/issues/373#issuecomment-814553922

    如果环境中已经有终端,为什么要从 PC 连接?

    【讨论】:

    • 我正在向熟悉这些工具的观众教授 docker。我想向他们展示使用 docker 测试不同数据库的速度。
    猜你喜欢
    • 2020-09-28
    • 1970-01-01
    • 2020-02-18
    • 2017-06-02
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    相关资源
    最近更新 更多