Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect with filezilla to docker container

Tags:

I am running docker containers on Google Cloud virtual machine. I am trying for hours to connect from filezilla on my local computer to an running docker container. I have started docker image like this:

docker run -t -d --name test -p 2222:22 --link postgres7:postgres7 random_image /bin/bash

In my filezilla connection configuration I have set:

Host: Google Cloud IP address
Port: 2222
Protocol: SFTP
Logon Type: Normal
User: root (without password)

When trying to connect I get this error:

Status: Connecting to x.x.x.x:2222...
Response:   fzSftp started
Command:    open "[email protected]" 2222
Error:  Connection refused
Error:  Could not connect to server

I have opened ports on google cloud engine.

like image 677
Tomislav Brabec Avatar asked Jul 14 '16 12:07

Tomislav Brabec


People also ask

Can I Sftp on Docker container?

The SFTP server can be easily deployed to any platform that can host containers based on Docker. Below are deployment methods for: Docker CLI. Docker-Compose.

Does Docker support cross platform?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

Can Docker communicate with localhost?

docker run --network="host" Alternatively you can run a docker container with network settings set to host . Such a container will share the network stack with the docker host and from the container point of view, localhost (or 127.0.0.1 ) will refer to the docker host.


1 Answers

First, it is not recommended to install ssh server on docker containers but here is how I did it:

  1. Install ssh client

apt-get install openssh-server

  1. Set password on root (or any user you want to connect with)

passwd (enter password twice)

  1. In /etc/ssh/sshd_config change:

PermitRootLogin without-password

to

PermitRootLogin yes

  1. Restart ssh server

/etc/init.d/ssh restart

And now you will be able to connect with any ftp client as root to your docker container with password that you set.

like image 86
Tomislav Brabec Avatar answered Oct 30 '22 13:10

Tomislav Brabec