`
sillycat
  • 浏览: 2539070 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Play Raspberry Pi(7)FTP in Docker

 
阅读更多
Play Raspberry Pi(7)FTP in Docker

1 Set up PureFTPD in Ubuntu

PureFTPD on ubuntu
http://www.jianshu.com/p/fa037a4866e6
http://i.linuxtoy.org/docs/guide/ch23s05.html
http://wiki.ubuntu.org.cn/Pure-ftpd%E6%9C%8D%E5%8A%A1%E5%AE%89%E8%A3%85%E8%AE%BE%E7%BD%AE

http://4408149.blog.51cto.com/4398149/1735815

Install command
> sudo apt-get install pure-ftpd

Create group
> sudo groupadd ftpgroup

Create user
> sudo useradd -g ftpgroup -d /var/ftp/sillycat -s /bin/bash sillycat

Create Virtual User
> sudo pure-pw useradd sillycat -u sillycat -g ftpgroup -d /var/ftp/sillycat

first sillycat is virtual user
second sillycat is the system user, lock the user in the directory.

Create virtual user data
> sudo pure-pw mkdb

Soft link the user db to auth directory
> sudo ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb

Restart the server
> sudo /etc/init.d/pure-ftpd restart
Restarting ftp server: Running: /usr/sbin/pure-ftpd -l puredb:/etc/pure-ftpd/pureftpd.pdb -l pam -8 UTF-8 -u 1000 -J ALL:!aNULL:!SSLv3 -O clf:/var/log/pure-ftpd/transfer.log -E -B

Permission
> sudo chmod -R 777 /var/ftp

Verify the installation
http://sillycat.iteye.com/blog/2255064

> sudo apt-get install ftp

> ftp localhost 21

ftp> put README.md

2 Set up PureFTPD in Docker on Ubuntu
Check docker version
> docker version
Client:
Version:      1.11.2
API version:  1.23
Go version:   go1.5.4
Git commit:   b9f10c9
Built:        Wed Jun  1 21:47:50 2016
OS/Arch:      linux/amd64

Server:
Version:      1.11.2
API version:  1.23
Go version:   go1.5.4
Git commit:   b9f10c9
Built:        Wed Jun  1 21:47:50 2016
OS/Arch:      linux/amd64

All similar to non docker, the docker file is as follow:
> cat Dockerfile
#Set up FTP in Docker

#Prepre the OS
FROM ubuntu:14.04
MAINTAINER Carl Luo <luohuazju@gmail.com>

ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -qq update
RUN apt-get -qqy dist-upgrade

#Install the tools
RUN apt-get -qqy install pure-ftpd

#set up config and users
RUN mkdir -p /var/ftp
RUN chmod -R 777 /var/ftp
RUN groupadd ftpgroup
RUN useradd luohuazju
RUN { echo kaishi; echo kaishi; } | passwd luohuazju
RUN { echo kaishi; echo kaishi; } | pure-pw useradd luohuazju -u luohuazju -g ftpgroup -d /var/ftp/luohuazju
RUN pure-pw mkdb
RUN ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb

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

> cat Makefile
IMAGE=sillycat/public
TAG=ubuntu-pureftpd
NAME=ubuntu-pureftpd

docker-context:

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

run:
docker run -d -p 21:21 -p 30000-30009:30000-30009 -v $(shell pwd)/ftp:/var/ftp --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 21:21 -p 30000-30009:30000-30009 -v $(shell pwd)/ftp:/var/ftp --name $(NAME) $(IMAGE):$(TAG) /bin/bash

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

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}


> cat start.sh
#!/bin/sh -ex

#start the ftp
/etc/init.d/pure-ftpd restart
#tail the logging
tail -f /dev/null

Exception:
421 Unable to switch capabilities : Operation not permitted

Solution:
I am running that in one virtual ubuntu system. I will directly run that in my CentOS or RaspberryPi.
It works on CentOS.

3 PureFTP runs on RaspberryPi
> docker version
Client:
Version:      1.10.3
API version:  1.22
Go version:   go1.4.3
Git commit:   20f81dd
Built:        Thu Mar 10 22:23:48 2016
OS/Arch:      linux/arm

Server:
Version:      1.10.3
API version:  1.22
Go version:   go1.4.3
Git commit:   20f81dd
Built:        Thu Mar 10 22:23:48 2016
OS/Arch:      linux/arm

All the configurations are the same for RaspberryPi

I was doing the things on and external USB hard driver through NTFS.
I get issues when I run the docker application
Error Message:
docker: Error response from daemon: error creating overlay mount to /mnt/driver1/data/docker/overlay/2a1f2702b7538a9ea5e070bd708e7f97c0df255fb76d73b48b2543f5c5fb40e1-init/merged: invalid argument.
See 'docker run --help'.
Makefile:12: recipe for target 'run' failed
make: *** [run] Error 125

Error Message:
exec format error
Cannot start container 78e7cf21e232f36a387b28cb6b5b5421a922b553ef56271f911f24fd45c8b473: [9] System error: exec format error

Solution:
Do NOT use USB Driver to store docker images. Only configure the tmp directory to USB
> cat /etc/default/docker
# Docker Upstart and SysVinit configuration file

# This is also a handy place to tweak where Docker's temporary files go.
export TMPDIR="/opt/docker/tmp"

> docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 3
Server Version: 1.10.3
Storage Driver: overlay
Backing Filesystem: extfs

The Dockerfile need to be changed, it is not right to run things like that directly on raspberryPI arm system.
#Prepre the OS
#FROM ubuntu:14.04
FROM resin/rpi-raspbian:jessie

Exception:
421 Unable to switch capabilities : Operation not permitted

Solution:
http://dikant.de/2009/01/22/setting-up-pureftpd-on-a-virtual-server/

https://github.com/stilliard/docker-pure-ftpd/blob/master/Dockerfile
We need build the PureFTP ourselves with options.
https://hub.docker.com/r/stilliard/pure-ftpd/~/dockerfile/

> cat 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
RUN apt-get -y --force-yes install dpkg-dev debhelper

#Install the tools
RUN apt-get -y build-dep pure-ftpd
RUN mkdir /tmp/pure-ftpd/ && \
cd /tmp/pure-ftpd/ && \
apt-get source pure-ftpd && \
cd pure-ftpd-* && \
sed -i '/^optflags=/ s/$/ --without-capabilities/g' ./debian/rules && \
dpkg-buildpackage -b -uc
RUN dpkg -i /tmp/pure-ftpd/pure-ftpd-common*.deb
RUN apt-get -y install openbsd-inetd
RUN dpkg -i /tmp/pure-ftpd/pure-ftpd_*.deb

# Prevent pure-ftpd upgrading
RUN apt-mark hold pure-ftpd pure-ftpd-common

#set up config and users
RUN echo 'yes' > /etc/pure-ftpd/conf/VerboseLog
RUN mkdir -p /var/ftp/xxxx1
RUN mkdir -p /var/ftp/xxxx2
RUN chmod -R 777 /var/ftp
RUN groupadd ftpgroup
RUN useradd xxxx1
RUN useradd xxxx2
RUN { echo aaaa1; echo aaaa1; } | passwd xxxx1
RUN { echo aaaa2; echo aaaa2; } | passwd xxxx2
RUN { echo aaaa1; echo aaaa1; } | pure-pw useradd xxxx1 -u xxxx1 -g ftpgroup -d /var/ftp/xxxx1
RUN { echo aaaa2; echo aaaa2; } | pure-pw useradd xxxx2 -u xxxx2 -g ftpgroup -d /var/ftp/xxxx2
RUN pure-pw mkdb
RUN ln -s /etc/pure-ftpd/conf/PureDB /etc/pure-ftpd/auth/60puredb

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

> cat start.sh
#!/bin/sh -ex

#start the ftp
/etc/init.d/pure-ftpd restart
#tail the logging
tail -f /dev/null

> cat Makefile
IMAGE=sillycat/public
TAG=ubuntu-pureftpd
NAME=ubuntu-pureftpd

docker-context:

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

run:
docker run -d -p 21:21 -p 30000-30009:30000-30009 -v $(shell pwd)/ftp:/var/ftp --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 21:21 -p 30000-30009:30000-30009 -v $(shell pwd)/ftp:/var/ftp --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}


That is done. It is running great there.
> docker ps
CONTAINER ID        IMAGE                             COMMAND             CREATED             STATUS              PORTS                                                      NAMES
c7bed6579780        sillycat/public:ubuntu-pureftpd   "./start.sh"        2 days ago          Up 2 days           0.0.0.0:21->21/tcp, 0.0.0.0:30000-30009->30000-30009/tcp   ubuntu-pureftpd

And when we are using FileZilla, make sure we are setting Transfer Settings to “Active”.

References:
PureFTPD
https://github.com/stilliard/docker-pure-ftpd/blob/master/Dockerfile

https://www.pureftpd.org/project/pure-ftpd/download
http://stackoverflow.com/questions/23930167/installing-pure-ftpd-in-docker-debian-wheezy-error-421
http://wiki.ubuntu.org.cn/Pure-ftpd%E6%9C%8D%E5%8A%A1%E5%AE%89%E8%A3%85%E8%AE%BE%E7%BD%AE

One Java FTP
http://sillycat.iteye.com/blog/2255064
分享到:
评论

相关推荐

    Raspberry Pi 4 Beginner’s Guide.pdf

    In our opinion, you will certainly adore the Raspberry Pi 4. Ultra-small, affordable, even cheaper than most video games, you can use the Pi to build robots, learn coding and create all sorts of...

    Raspberry Pi Zero Cookbook

    In his spare time, he is an Internet of Things enthusiast and has spoken on the wonders of the Raspberry Pi at conferences and user groups. He loves his Raspberry Pis. He has also built his own 3D ...

    Wiley Learning Python with Raspberry Pi 2014

    《Wiley Learning Python with Raspberry Pi 2014》是一本专为初学者设计的教程,旨在引导读者通过树莓派这一小型计算机平台学习Python编程。这本书由2014年出版,当时Python已是编程界的热门语言,而树莓派因其低...

    Raspberry Pi LED Blueprints(PACKT,2015)

    This book will provide you with the ability to control LEDs from Raspberry Pi, starting from describing an idea through designing and implementing several projects based on LEDs, such as, 7-segments,...

    Adventures in Raspberry Pi (3rd edition).pdf

    《Raspberry Pi探险记(第三版)》是由Carrie Anne Philbin撰写,首次出版于2017年,并由John Wiley & Sons, Inc.出版。这本书旨在向读者介绍Raspberry Pi——一种由Raspberry Pi基金会推出的低成本、信用卡大小的...

    rpi-hubot-docker-template:Raspberry Pi上的Hubot Docker容器模板

    rpi-hubot-docker-template Raspberry Pi上的Hubot Docker容器模板如何在Raspberry Pi上使用Docker 上安装。 请参阅以设置环境。用法克隆此仓库 $ git clone https://github.com/knjcode/rpi-hubot-docker-template$...

    Getting Started with Raspberry Pi Zero.pdf

    Raspberry Pi Zero is half the size of Raspberry Pi A, only with twice the utility. At just three centimeters wide, it packs in every utility required for full-fledged computing tasks. This practical ...

    Raspberry Pi快速入门指南-奥松

    《Raspberry Pi快速入门指南》是一本面向初学者的实用手册,由Maik Schmidt撰写,国内译者王峰、王江伟、王汝波共同翻译。该书为读者详细介绍了Raspberry Pi这一款迷你Linux计算机的使用方法,并指导用户如何通过...

    Raspberry Pi Cookbook.pdf

    The world of Raspberry Pi is evolving quickly, with many new interface boards and software libraries becoming available all the time. In this cookbook, prolific hacker and author Simon Monk provides ...

    docker-raspberrypi-4B.zip

    docker-arm_20.10.6 资源

    raspberrypi-rstudio:用于Raspberry Pi的RStudio-Docker构建和运行时环境

    raspberrypi-rstudio:用于Raspberry Pi的RStudio-Docker构建和运行时环境

    Raspberry.Pi.Home.Automation.with.Arduino.2nd.Edition.178439

    Any experience in using the Raspberry Pi would be an added advantage. In Detail Revolutionize the way you interact with your home and become part of the rapidly growing group of hobbyists and ...

    Raspberry.Pi.Computer.Architecture.Essentials.17843

    In this book, we explore Raspberry Pi 2's hardware through a number of projects in a variety of programming languages. We will start by exploring the various hardware components in detail, which will ...

    基于RaspberryPi实现的智能家居.docx

    ### 基于Raspberry Pi实现的智能家居 #### 1.1 课题背景与意义 随着信息技术的发展,智能家居成为越来越多人关注的焦点。本课题旨在探索利用Raspberry Pi这一低成本且功能强大的微型计算机来实现智能家居控制系统...

    Raspberry Pi

    CHAPTER 1: INTRODUCTION TO RASPBERRY PI THE EVOLUTION OF RASPBERRY PI 2 THE UNIQUE FEATURES: MODEL A MODEL A+ MODEL B MODEL B+ SHOULD YOU BUY THE LATEST RASPBERRY PI 2, IF YOU HAVE PREVIOUS MODELS? ...

    在Raspberry Pi上搭建ARM Cortex-M3开发环境

    在Raspberry Pi上搭建ARM Cortex-M3开发环境是一项有趣且实用的任务,这使得开发者能够利用Raspberry Pi的强大计算能力来开发基于STM32微控制器的项目。STM32是一款广泛使用的基于ARM Cortex-M3内核的微控制器,适用...

Global site tag (gtag.js) - Google Analytics