stilliard / docker-pure-ftpd

Docker Pure-ftpd Server
https://hub.docker.com/r/stilliard/pure-ftpd/
MIT License
857 stars 325 forks source link

How can I give a user access to a docker volume or path outside the ftp container? #148

Open jaywork2020 opened 4 years ago

jaywork2020 commented 4 years ago

First of all, I want to thank you for this image.

I set it and and it seems to be working fine. But I need to give a user access files on the server not in the container

for example the following command creates a user called bob and gives him access to /home/ftpusers/bob inside the docker container.

pure-pw useradd bob -f /etc/pure-ftpd/passwd/pureftpd.passwd -m -u ftpuser -d /home/ftpusers/bob

How can I give the user bob access to the /home/ftpusers/bob path on the server not inside the container. Or to a docker volume.

For example, I have another docker container running a wordpress site. I want to be able to FTP into the docker volume that is hosting the wordpress. In my case the WordPress for this container are located on /data/mysitename/pubic_html so I want bob to be able to connect using FTP and manage the files on /data/mysitename/pubic_html.

How can I give a user access to a docker volume or a server location instead on a location on the container?

stilliard commented 4 years ago

Hey @jaywork2020 !

Thanks glad it's useful for you.

Sure thing, the workflow generally for this is to have your wordpress container expose the folder you need through a volume, and then expose the same volume to the ftp docker container.

Here's an example doing this using docker compose: https://github.com/stilliard/docker-pure-ftpd/wiki/Docker-stack-with-Wordpress-&-FTP

Hope it helps.

jaywork2020 commented 4 years ago

@stilliard Thank you for your help. Do I still create the user like this when mounting to a path on the server?

Assume my volume is set like this

    volumes:
      - ./data/wordpress:/var/www/html
      - ./data/ftp:/etc/ssl/private
pure-pw useradd bob -f /etc/pure-ftpd/passwd/pureftpd.passwd -m -u ftpuser -d /data/wordpress

I attempted the above, but when trying to FTP into the server it fails. Here are the logs from the FTP attempt

Status: Resolving address of ftpusa.mydomain.com
Status: Connecting to SERVER_IP_ADDRESS:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Status: Logged in
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/" is your current location
Command:    TYPE I
Response:   200 TYPE is now 8-bit binary
Command:    PASV
Error:  Connection timed out after 20 seconds of inactivity
Error:  Failed to retrieve directory listing
Status: Disconnected from server
Status: Resolving address of ftpusa.mydomain.com
Status: Connecting to SERVER_IP_ADDRESS:21...
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Status: Logged in
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/" is your current location
Command:    TYPE I
Response:   200 TYPE is now 8-bit binary
Command:    PASV
Error:  Connection timed out after 20 seconds of inactivity
Error:  Failed to retrieve directory listing

How can I get this to work?

stilliard commented 4 years ago

Hi @jaywork2020 Couple things to check, are you setting your PUBLICHOST env param, also are you exposing the needed ports? More info on these in the readme if that helps.

jaywork2020 commented 4 years ago

@stilliard Yes I did

Here is how I create the ftpd_server using the composer file

version: "3"
services:

    ftpd_server:
        image: stilliard/pure-ftpd
        container_name: ftpd_server
        restart: always
        ports:
            - "21:21"
            - "30000-30009:30000-30009"
        environment:
            PUBLICHOST: ftpusa.mydomain.com
        volumes:
            - /data/wordpress_app/public_html:/var/www/html
            - /ftp_data/data:/home/usrname/
            - /ftp_data/passwd:/etc/pure-ftpd/passwd
            - /ftp_data/ssl:/etc/ssl/private

    # Other services were removed
networks:
    default:
       external:
           name: nginx-network

I want the new user to FTP into /data/wordpress_app/public_html or /data/wordpress_app

stilliard commented 4 years ago

Hi @jaywork2020 Sorry tor the delay there.

Does the same error happen if you set your ftp user to a non volume folder?

Wondering if it's an issue ftping at all or just with the volumed folder.

Thanks

inv1sible commented 2 years ago

not sure if still an issue, but its open, so....

when mounting volumes in a docker file its - /dir-on-local-host:/dir-inside-container

when using - /data/wordpress_app/public_html:/var/www/html the dir-on-local-host must exist in the desired location on the host (it will be created anyway if not existing) BUT dir-inside-container will be needed in ftp-docker-container... I am pretty sure it is not existing... and will not be created

so you need in ftp docker-compose.yml:

- /data/wordpress_app/public_html:/home/usrname/

and in wordpress docker-compose.yml:

- /data/wordpress_app/public_html:/var/www/html