dongnan
总版主
总版主
  • 粉丝52
  • 发帖数2165
  • 铜币13236枚
  • 威望5838点
  • 银元150个
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 原创写手
阅读:69回复:0

如何创建一个 vsftp 的 Docker容器?

楼主#
更多 发布于:2018-11-06 16:22
目标
使用 docker-compose,创建一个 vsftp 容器。

环境
1. docker-compose: 1.11.2
2. docker: 17.12.1-ce
3. image: fauria/vsftpd

配置文件
cat docker-compose.yml
version: '2'
services:
  ftpd:
    image: fauria/vsftpd
    container_name: vsftpd
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - web-data:/home/vsftpd
    environment:
      - TZ=Asia/Chongqing
      - FTP_USER=dongnan
      - FTP_PASS=zongming.net
    ports:
      - "20:20"
      - "21:21"
      - "21100-21110:21100-21110"

volumes:
    web-data:
      driver: local
# FTP_USER/FTP_PASS 变量是创建的用户名与密码,映射端口: 20/21/21100-21110

步骤
1. 创建容器
docker-compose up -d
Starting vsftpd

2. 容器日志
docker-compose logs --tail 5
Attaching to vsftpd
vsftpd  |     ---------------
vsftpd  |     · FTP User: dongnan
vsftpd  |     · FTP Password: zongming.net
vsftpd  |     · Log file: /var/log/vsftpd/vsftpd.log
vsftpd  |     · Redirect vsftpd log to STDOUT: No.

3. 测试FTP
ftp 6.6.6.6
Connected to 6.6.6.6.
220 (vsFTPd 3.0.2)
Name (6.6.6.6:dongnan): dongnan
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
#
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.
#
ftp> put exam.txt
local: exam.txt remote: exam.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
2177 bytes sent in 0.00 secs (70865.9 kB/s)
#
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-------    1 ftp      ftp          2177 Nov 05 08:25 exam.txt
226 Directory send OK.
#
ftp> get exam.txt
local: exam.txt remote: exam.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for exam.txt (2177 bytes).
226 Transfer complete.
2177 bytes received in 0.00 secs (1230.3 kB/s)
#
ftp> delete exam.txt
250 Delete operation successful.
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
226 Directory send OK.
#
ftp> quit
221 Goodbye.

参考: https://hub.docker.com/r/fauria/vsftpd/
#
游客

返回顶部