Transfer Data to a SFTP Server with Docker
If you want to upload files to your server and access them from inside you might want to set up SFTP.
SFTP is the more secure version of FTP.
If you want to install an FTP Server on your Raspberry Pi click here.
1.1 Create the Docker-Compose File
First create a new folder and cd into it.
mkdir ftp && cd ftp
Create a docker-compose file.
And paste this:
version: '3' services: sftp: container_name: sftp_server image: atmoz/sftp volumes: - ./users.conf:/etc/sftp/users.conf:ro - ./home:/home ports: - "2222:22"
1.2 Creating Users
Now create a new file called “users.conf”
And paste your user data:
The format is as follows:
If you want to use an encrypted password add “:e” after the encrypted password.
Now spin up the container:
docker-compose up -d
1.3 Creating writable directories
Now cd into the home directory of your user:
In here we’ll have to create a new directory.
This is going to be the only directory we can write to.
To make this folder writable, execute this command:
chmod 756 files
2. Connecting to your Server
Connect to your server like this: