[英]FTP file into docker container on remote server
How can I transfer transfer files into a Docker container running on a remote Ubuntu server using an FTP client? 如何使用FTP客户端将传输文件传输到在远程Ubuntu服务器上运行的Docker容器中? I can SSH into the server and use
docker cp
, which works fine. 我可以SSH到服务器并使用
docker cp
,这很好。 But I have a client who needs to be able to do so with something like FileZilla. 但我有一个客户需要能够使用像FileZilla这样的东西。 Is this possible?
这可能吗?
Im not an expert with docker, but you could try this: 我不是docker的专家,但你可以试试这个:
You can expose several ports when you run the container. 运行容器时可以显示多个端口。 So, you can expose the FTP port also, something like this.
所以,你也可以暴露FTP端口,就像这样。
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. 在这个使用
-p 3001:21
示例中,您将容器的端口21暴露给服务器的端口3001,因此您可以使用服务器的ip输入filezilla作为主机,输入3001作为端口。
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 (ie your ENTRYPOINT application). 如果您需要进行测试: Docker容器不会公开FTP服务器,因为容器应该只运行1个进程(即您的ENTRYPOINT应用程序)。 However, you can use commands like
docker cp
to copy files from/to running containers. 但是,您可以使用
docker cp
类的命令将文件复制到正在运行的容器中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.