I'm trying to connect with FTP server, deployed from docker image, using Apache client:
import .apachemons.ftp.FTPClient
import java.io.IOException
object FtpClient {
def main(args: Array[String]): Unit = {
val ftpClient = new FTPClient()
try {
ftpClient.connect("localhost", 21)
val success = ftpClient.login("one", "1234")
if (success) {
println("Success connect")
}
} catch {
case e: IOException => throw new RuntimeException(e)
} finally {
//
}
}
}
FTP server run by:
docker run -d -p 21:21 -p 21000-21010:21000-21010 -e USERS="one|1234" -e ADDRESS=ftp.site.domain delfer/alpine-ftp-server
And I receive the following error:
Exception in thread "main" java.lang.RuntimeException: .apachemons.ftp.FTPConnectionClosedException: Connection closed without indication.
at ru.spb.client.FtpClient$.main(FtpClient.scala:23)
at ru.spb.client.FtpClient.main(FtpClient.scala)
Caused by: .apachemons.ftp.FTPConnectionClosedException: Connection closed without indication.
at .apachemons.ftp.FTP.getReply(FTP.java:568)
at .apachemons.ftp.FTP.getReply(FTP.java:556)
EDIT:
Docker logs returns:
Changing password for one
New password:
Bad password: too short
Retype password:
adduser: /ftp/one: No such file or directory
passwd: password for one changed by root
seems like pidfd_open syscall does not work, falling back to
polling
failed to watch for direct child exit (pidfd_open error): Operation not permitted
Maybe I miss some significant connection settings?
I'm trying to connect with FTP server, deployed from docker image, using Apache client:
import .apachemons.ftp.FTPClient
import java.io.IOException
object FtpClient {
def main(args: Array[String]): Unit = {
val ftpClient = new FTPClient()
try {
ftpClient.connect("localhost", 21)
val success = ftpClient.login("one", "1234")
if (success) {
println("Success connect")
}
} catch {
case e: IOException => throw new RuntimeException(e)
} finally {
//
}
}
}
FTP server run by:
docker run -d -p 21:21 -p 21000-21010:21000-21010 -e USERS="one|1234" -e ADDRESS=ftp.site.domain delfer/alpine-ftp-server
And I receive the following error:
Exception in thread "main" java.lang.RuntimeException: .apachemons.ftp.FTPConnectionClosedException: Connection closed without indication.
at ru.spb.client.FtpClient$.main(FtpClient.scala:23)
at ru.spb.client.FtpClient.main(FtpClient.scala)
Caused by: .apachemons.ftp.FTPConnectionClosedException: Connection closed without indication.
at .apachemons.ftp.FTP.getReply(FTP.java:568)
at .apachemons.ftp.FTP.getReply(FTP.java:556)
EDIT:
Docker logs returns:
Changing password for one
New password:
Bad password: too short
Retype password:
adduser: /ftp/one: No such file or directory
passwd: password for one changed by root
seems like pidfd_open syscall does not work, falling back to
polling
failed to watch for direct child exit (pidfd_open error): Operation not permitted
Maybe I miss some significant connection settings?
Share Improve this question edited Mar 9 at 17:26 f_puras 2,5044 gold badges36 silver badges46 bronze badges asked Mar 9 at 11:02 JellyJelly 1,3325 gold badges26 silver badges58 bronze badges 01 Answer
Reset to default -1FTP Container - Docker run command:
docker run -d \
-p 21:21 \
-p 21000-21010:21000-21010 \
-e USERS="one|Passw0rd!" \
-e ADDRESS=ftp.site.domain \
delfer/alpine-ftp-server
-e USERS="one|Passw0rd!"
, Password1234
is too short, so change password toPassw0rd!
or others-e ADDRESS=ftp.site.domain
,ftp.site.domain
is your ftp server name.
edit your /etc/hosts
add ftp.site.domain
to 127.0.0.1
127.0.0.1 localhost ftp.site.domain
A quick alternative
find ftp container id
docker ps
if container id is 05da9c08858f
open into ftp container
docker exec -it 05da9c08858f sh
Check if the ftp service is running?
in container , run command:
netstat -tulnp | grep :21
if return nothing, ftp service is not running.
start ftp service
vsftpd /etc/vsftpd/vsftpd.conf
run command again:
netstat -tulnp | grep :21
return: ( ftp service is running. )
netstat -tulnp | grep :21
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 45/vsftpd
exit container:
exit
Note:
I didn’t spend more time to check why the ftp service was not started by default in the docker run command, so I just provide a quick solution: enter the Container and start the ftp service manually.
Your Test App
FtpClient.scala
- Change FTP Server to
ftp.site.domain
- Change Password to
Passw0rd!
import .apachemons.ftp.FTPClient
import java.io.IOException
object FtpClient {
def main(args: Array[String]): Unit = {
val ftpClient = new FTPClient()
try {
ftpClient.connect("ftp.site.domain", 21)
val success = ftpClient.login("one", "Passw0rd!")
if (success) {
println("Success connect")
}
} catch {
case e: IOException => throw new RuntimeException(e)
} finally {
//
}
}
}
Download jar file:
Download commons-net-3.9.0.jar(https://repo1.maven./maven2/commons-net/commons-net/3.9.0/commons-net-3.9.0.jar)
Check version
$ scala -version
Scala code runner version: 1.5.4
Scala version (default): 3.6.4
Run App
$ scala -classpath "commons-net-3.9.0.jar" FtpClient.scala
Compiling project (Scala 3.6.4, JVM (21))
Compiled project (Scala 3.6.4, JVM (21))
Success connect