Raspberry and JavaFTP on Docker

本文介绍如何在Raspberry Pi上使用Java和Docker搭建FTP服务器,包括配置监听端口、SSL证书、被动模式端口范围等。通过提供的Makefile和Dockerfile,可以快速部署并运行FTP服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Raspberry and JavaFTP on Docker

Enable the JavaFTP server on docker.

Here is the Makefile
IMAGE=sillycat/public
TAG=raspberrypi-javaftp
NAME=raspberrypi-javaftp

prepare:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-arm32-vfp-hflt.tar.gz" -P install/
wget http://apache.mirrors.lucidnetworks.net/mina/ftpserver/1.0.6/dist/ftpserver-1.0.6.tar.gz -P install/
#tar zxvf ftpserver-1.0.6.tar.gz
#tar -cvzf ./apache-ftpserver-1.0.6.tgz ./apache-ftpserver-1.0.6

docker-context:

build: docker-context
# docker build --no-cache -t $(IMAGE):$(TAG) .
docker build -t $(IMAGE):$(TAG) .

run:
docker run -d -p 2121:2121 -p 30000-30039:30000-30039 -v /opt/disk1/sillycat:/tool/apache-ftpserver-1.0.6/res/home/sillycat --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 2121:2121 -p 30000-30039:30000-30039 -v /opt/disk1/sillycat:/tool/apache-ftpserver-1.0.6/res/home/sillycat --name $(NAME) $(IMAGE):$(TAG) /bin/bash

clean:
docker stop ${NAME}
docker rm ${NAME}

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}:${TAG}

fetch:
docker pull ${IMAGE}:${TAG}


Here is the Dockerfile
#Set up FTP in Docker

#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <luohuazju@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
RUN echo "deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
" > /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y dist-upgrade

#install java env
ADD install/jdk-8u91-linux-arm32-vfp-hflt.tar.gz /tool/
RUN update-alternatives --install /usr/bin/java java /tool/jdk1.8.0_91/bin/java 1

#install ftp soft
ADD install/apache-ftpserver-1.0.6.tgz /tool/

#configure the server
ADD conf/ftpd-typical.xml /tool/apache-ftpserver-1.0.6/res/conf/
ADD conf/users.properties /tool/apache-ftpserver-1.0.6/res/conf/

RUN mkdir -p /tool/apache-ftpserver-1.0.6/res/home/sillycat
RUN mkdir -p /tool/apache-ftpserver-1.0.6/res/home/kiko
RUN mkdir -p /tool/apache-ftpserver-1.0.6/res/home/xieqiuyuan

#start the application
EXPOSE 2121 30000-30040
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]

Here is the start.sh
#!/bin/sh -ex

#start the ftp
cd /tool/apache-ftpserver-1.0.6
bin/ftpd.sh res/conf/ftpd-typical.xml

The typical configuration for ftp in ftp-typical.xml is as follow:
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd

"
id="nasServer"
max-logins="20"
anon-enabled="false"
max-login-failures="3"
login-failure-delay="500">
<listeners>
<nio-listener name="default" port="2121">

<ssl>

<keystore file="./res/ftpserver.jks" password="password" />
</ssl>
<data-connection idle-timeout="60">
<active enabled="true" local-port="30040" ip-check="true" />
<passive ports="30000-30039" external-address="72.179.1.15" />
</data-connection>

</nio-listener>

</listeners>
<file-user-manager file="./res/conf/users.properties" encrypt-passwords="false"/>
</server>

It works great. The only thing is that when I try to clean the old directory. I delete some directories which are useful. My god.

References:
http://sillycat.iteye.com/blog/2255064

https://mina.apache.org/ftpserver-project/configuration_passive_ports.html
https://mina.apache.org/ftpserver-project/configuration_listeners.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值