vsFTPD Server in a Docker
193
This vsftpd docker image is based on official oraclelinux:8-slim image and comes with following features:
This image uses environment variables to allow the configuration of some parameters at run time:
FTP_FORCE_SSLFTP_LOG_FILE/logs/vsftpd/vsftpd.log.FTP_LISTEN_PORTdocker -p parameter.FTP_DATA_PORTdocker -p parameter.FTP_PASV_ADDRESSFTP_PASV_ADDR_RESOLVEFTP_PASV_MIN_PORTdocker -p parameter.FTP_PASV_MAX_PORTFTP_PASV_PROMISCUOUSFTP_PORT_PROMISCUOUSFTP_REVERSE_LOOKUP_ENABLEFTP_ADM_NAMEFTP_ADM_NAME environment variable at run time, admin will be used by default.FTP_ADM_PASSFTP_ADM_PASS environment variable at run time, passw0rd will be used by default.FTP_ANON/var/ftp/anonymous directory.FTP_ANON_MODENO reade onlyRW reade write and disallow deleteALL reade write and allow delete/var/ftp/anonymous directory.Variable name: FTP_USER_1,,,N
Default value: not defined
Accepted values: USERNAME:PASSWORD:LOCAL_ROOT:ACCESS_MODE:CMD:ANON
USERNAME Any string. Avoid whitespaces and special chars.
PASSWORD Any string.
LOCAL_ROOT Any sub folder only in the dir /var/ftp/pub.
ACCESS_MODE Access mode. <RW|RO>
CMD Set to YES if you want to allow change the current directory to DIR. <NO|YES>
ANON Set to YES if you want to allow anonymous access to files in LOCAL_ROOT directory. <NO|YES>
mount --bindis used to configure anonymous access, but this not supporting in docker swarm. Only if set to YES, required--cap-add=SYS_ADMINor--privileged=truewhen run your container to use mount inside container. Instead of --privileged you can be a bit more fine-grained and use --cap-add=SYS_ADMIN.
Description: Adds multiple users for the workloads.
docker build -f Dockerfile -t vsftpd:latest .
docker volume create vsftpd_data
docker volume create vsftpd_logs
3.1) Docker Container:
docker run -dit \
-e "FTP_FORCE_SSL=NO" \
-e "FTP_LOG_FILE=NO" \
-e "FTP_LISTEN_PORT=21" \
-e "FTP_DATA_PORT=20" \
-e "FTP_PASV_ADDRESS=NO" \
-e "FTP_PASV_ADDR_RESOLVE=NO" \
-e "FTP_PASV_MIN_PORT=30025" \
-e "FTP_PASV_MAX_PORT=30050" \
-e "FTP_PASV_PROMISCUOUS=NO" \
-e "FTP_PORT_PROMISCUOUS=NO" \
-e "FTP_REVERSE_LOOKUP_ENABLE=NO" \
-e "FTP_ADM_NAME=admin" \
-e "FTP_ADM_PASS=passw0rd" \
-e "FTP_ANON=YES" \
-e "FTP_ANON_MODE=RW" \
-e "FTP_USER_1=user1:pass1:/var/ftp/pub/data1:rw:yes:yes" \
-e "FTP_USER_2=user2:pass2:/var/ftp/pub/data1/data2:ro:yes:no" \
-e "FTP_USER_3=user3:pass3:/var/ftp/pub/data1/data3:rw:no:yes" \
--privileged=true \
--restart unless-stopped \
--stop-timeout 60 \
--memory="2048m" --cpus=1 \
--network=bridge -p 20:20/tcp -p 21:21/tcp -p 30025-30050:30025-30050/tcp \
-v vsftpd_data:/var/ftp/pub \
-v vsftpd_logs:/logs \
--name vsftpd \
vsftpd:latest
3.2) Docker Compose (standalone):
docker-compose -p vsftpd -f docker-compose.yml up -d
version: '3.7'
services:
vsftpd:
image: vsftpd:latest
container_name: vsftpd
privileged: true
restart: unless-stopped
volumes:
- vsftpd_logs:/logs:rw
- vsftpd_data:/var/ftp/pub:rw
ports:
- "20:20/tcp"
- "21:21/tcp"
# - "30020:30020/tcp"
# - "30021:30021/tcp"
- "30025-30050:30025-30050/tcp"
network_mode: bridge
environment:
- "FTP_FORCE_SSL=YES"
- "FTP_LOG_FILE=NO"
- "FTP_LISTEN_PORT=21"
- "FTP_DATA_PORT=20"
- "FTP_PASV_ADDRESS=ftp.example.com"
- "FTP_PASV_ADDR_RESOLVE=YES"
- "FTP_PASV_MIN_PORT=30025"
- "FTP_PASV_MAX_PORT=30050"
- "FTP_PASV_PROMISCUOUS=NO"
- "FTP_PORT_PROMISCUOUS=NO"
- "FTP_REVERSE_LOOKUP_ENABLE=NO"
- "FTP_ADM_NAME=admin"
- "FTP_ADM_PASS=passw0rd"
- "FTP_ANON=YES"
- "FTP_ANON_MODE=ALL"
- "FTP_USER_1=user1:pass1:/var/ftp/pub/data1:rw:yes:yes"
- "FTP_USER_2=user2:pass2:/var/ftp/pub/data2:ro:yes:yes"
- "FTP_USER_3=user3:pass3:/var/ftp/pub/data3:rw:no:yes"
stop_grace_period: 1m
volumes:
vsftpd_logs:
external: true
vsftpd_data:
external: true
docker ps -a
docker image ls
docker exec -it vsftpd bash
docker logs vsftpd --follow
docker container start vsftpd
docker container stop vsftpd
docker container rm -f vsftpd
docker network rm vsftpd_net
docker volume rm vsftpd_data
docker volume rm vsftpd_logs
docker image rm vsftpd:latest
Content type
Image
Digest
Size
58.8 MB
Last updated
almost 6 years ago
docker pull rlagutinhub/docker.vsftpd:v1