Sign inSign up

chonjay21/sftp

By chonjay21

•Updated about 6 years ago

SSH/Sftp based on official latest alpine image

Image
1

2.3K

chonjay21/sftp repository overview

⁠Sftp⁠

Docker Cloud Automated build Docker Cloud Build Status Docker Pulls GitHub Docker Stars GitHub stars

⁠Sftp based on official latest alpine image

  • Support Multiple architectures
  • Support ssh
  • Support sftp
  • Support ssh proxy tunnel
  • Support umask change
  • Support UserID|GroupID change
  • Support custom TimeZone
  • Support custom event script override

Our goal is to create a simple, consistent, customizable and convenient image using official image

Find me at:


⁠Supported Architectures

The architectures supported by this image are:

ArchitectureTag
x86-64amd64, latest
armhfarm32v7, latest
arm64arm64v8, latest

⁠Usage

Here are some example snippets to help you get started running a container.

⁠docker (simple)

docker run -e APP_USER_NAME=admin -e APP_USER_PASSWD=admin -e APP_UID=1000 -e APP_GID=1000 -p 22:22 -v /sftp/data:/home/sftp/data chonjay21/sftp

⁠docker

docker run \
  -e APP_USER_NAME=admin	\
  -e APP_USER_PASSWD=admin	\
  -e APP_UID=1000	\
  -e APP_GID=1000	\
  -e FORCE_REINIT_CONFIG=false                                        `#optional` \
  -e APP_UMASK=007                                                    `#optional` \
  -e APP_SSHD_PORT=22                                                 `#optional` \
  -e APP_MOTD_MSG="Welcome!!!"                                        `#optional` \
  -e TZ=America/Los_Angeles                                           `#optional` \
  -p 22:22 \
  -v /sftp/data:/home/sftp/data \
  -v /etc/ssh/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key:ro           `#optional` \
  -v /etc/ssh/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key:ro   `#optional` \
  chonjay21/sftp

⁠docker-compose

Compatible with docker-compose v2 schemas. (also compatible with docker-compose v3)

version: '2.2'
services:
  sftp:
    container_name: sftp
    image: "chonjay21/sftp:latest"
    ports:
      - "22:22"
    environment:
      - APP_USER_NAME=admin
      - APP_USER_PASSWD=admin
      - APP_UID=1000
      - APP_GID=1000
      - FORCE_REINIT_CONFIG=false                                                #optional
      - APP_UMASK=007                                                            #optional
      - APP_SSHD_PORT=22                                                         #optional
      - APP_MOTD_MSG="Welcome!!!"                                                #optional
      - TZ=America/Los_Angeles                                                   #optional
    volumes:
      - /sftp/data:/home/sftp/data
      - /etc/ssh/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key:ro                   #optional
      - /etc/ssh/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key:ro           #optional

⁠Parameters

ParameterFunctionOptional
-p 22for sftp port
-e APP_USER_NAME=adminfor login username
-e APP_USER_PASSWD=adminfor login password
-e APP_UID=1000for filesystem permission (userid)
-e APP_GID=1000for filesystem permission (groupid)
-e APP_UMASK=007for filesystem umask with sftpO
-e APP_SSHD_PORT=22for default ssh/sftp portO
-e APP_MOTD_MSG="Welcome!!!"for user login messageO
-e TZ=America/Los_Angelesfor timezoneO
-e FORCE_REINIT_CONFIG=falseif true, always reinitialize APP_USER_NAME etc ...O
-v /home/sftp/datafor data access with this container
-v /etc/ssh/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key:rofor custom host keyO
-v /etc/ssh/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key:rofor custom host keyO

⁠Event scripts

All of our images are support custom event scripts

ScriptFunction
/sources/sftp/eventscripts/on_pre_init.shcalled before initialize container (only for first time)
/sources/sftp/eventscripts/on_post_init.shcalled after initialize container (only for first time)
/sources/sftp/eventscripts/on_run.shcalled before running app (every time)

You can override these scripts for custom logic for example, if you don`t want your password exposed by environment variable, you can override on_pre_init.sh in this manner

⁠Exmaple - on_pre_init.sh

#!/usr/bin/env bash
set -e

APP_USER_PASSWD=mysecretpassword    # or you can set password from secret store and get with curl etc ...

⁠1. Override with volume mount

docker run \
  ...
  -v /sftp/on_pre_init.sh:/sources/sftp/eventscripts/on_pre_init.sh \
  ...
  chonjay21/sftp

⁠2. Override with Dockerfile and build

FROM chonjay21/sftp:latest
ADD host/on_pre_init.sh /sources/sftp/

⁠Logs to file

  • If you want to sshd access logs to file for fail2ban etc, you can use docker command with redirect in this manner.
docker logs --timestamps -f sftp >> access.log 2>&1 &
docker logs --timestamps -f sftp |tee -a access.log &

⁠License

View license information⁠ of this image.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Tag summary

Content type

Image

Digest

Size

9.8 MB

Last updated

about 6 years ago

docker pull chonjay21/sftp