FTP file into docker container on remote server
Asked Answered
S

2

9

How can I transfer transfer files into a Docker container running on a remote Ubuntu server using an FTP client? I can SSH into the server and use docker cp, which works fine. But I have a client who needs to be able to do so with something like FileZilla. Is this possible?

Shoreward answered 15/9, 2017 at 17:7 Comment(0)
S
7

Im not an expert with docker, but you could try this:

You can expose several ports when you run the container. So, you can expose the FTP port also, something like this.

docker run --name containername -p 3000:80 -p 3001:21 -d dockerimagename

In this example with the -p 3001:21 you are exposing your port 21 of the container to your port 3001 of the Server, so you can enter with filezilla with the ip of your server for host, and 3001 as port.

Selfseeker answered 15/9, 2017 at 17:32 Comment(1)
If anyone was able to use, what default username and password you gave? I am not able to connect to the Windows nanoserver container.Conjure
G
1

You should not transfer files into a running container image. It's a really bad idea.

Containers come and go all the time, most container orchestrators auto-restart containers, so the files you upload will be wiped as the container restarts cleanly form its original image.

Best-practice: Rebuild and redeploy the container image every time you need to make a change to a production application running inside a container.

If you need for testing purposes: Docker containers don't expose a FTP server, because containers are supposed to run only 1 process (i.e. your ENTRYPOINT application). However, you can use commands like docker cp to copy files from/to running containers.

Gean answered 28/8, 2019 at 18:27 Comment(1)
I agree with the point of container volatility, but I would try a different approach. I would map a volume with the host machine and create a individual FTP user pointing to the host's mapped directory.Regional

© 2022 - 2024 — McMap. All rights reserved.