使用 filezilla 连接到 docker 容器

Tom*_*bec 5 filezilla docker google-cloud-platform docker-container

我在 Google Cloud 虚拟机上运行 docker 容器。我尝试了几个小时从本地计算机上的 filezilla 连接到正在运行的 docker 容器。我已经开始这样的 docker 镜像:

docker run -t -d --name test -p 2222:22 --link postgres7:postgres7 random_image /bin/bash
Run Code Online (Sandbox Code Playgroud)

在我的 filezilla 连接配置中,我设置了:

主机:谷歌云 IP 地址
端口:2222
协议:SFTP
登录类型:普通
用户:root(无密码)

尝试连接时出现此错误:

Status: Connecting to x.x.x.x:2222...
Response:   fzSftp started
Command:    open "root@x.x.x.x" 2222
Error:  Connection refused
Error:  Could not connect to server
Run Code Online (Sandbox Code Playgroud)

我已经在谷歌云引擎上打开了端口。

Tom*_*bec 5

首先,不建议在 docker 容器上安装 ssh 服务器,但我是这样做的:

  1. 安装ssh客户端

apt-get install openssh-server

  1. 设置 root 密码(或任何您想要连接的用户)

passwd (enter password twice)

  1. 在 /etc/ssh/sshd_config 中更改:

PermitRootLogin without-password

PermitRootLogin yes

  1. 重启ssh服务器

/etc/init.d/ssh restart

现在,您将能够使用您设置的密码以 root 身份连接任何 ftp 客户端到您的 docker 容器。