问题
I'm looking to see if it is possible to somehow FTP into an already existing Docker container? For example, I'm using the dockerfile/ghost in combination with jwilder/nginx-proxy, and once I deploy/build a container, I'd like for the user to be able to FTP into the container running Ghost so they can upload additional files such as themes, stylesheets, etc. What would be the best method in accomplishing this? Thanks in advance!
回答1:
You have a few choices:
- run ftp in the Ghost container and expose a port
- use a host directory to store the user content and give them FTP to the host (not the best choice)
- map the same host directory into both the Ghost container and the FTP server container
Personally I thnk the last one is the best and the most work though the advantages will be worth it in the long run. I'm making the assumption that the uploaded content should survive container termination which is why I recommend using a mapped host directory, if this is not the case you can use linked volumes between the FTP container and the Ghost container.
回答2:
Probably the most "dockery" way of doing this would be to run a container for your ftp server (something such as this https://github.com/gizur/docker-ftpserver) and a separate one for ghost, then mount a common volume.
The best way to synchronize these is with a version 2 docker-compose.yml https://docs.docker.com/compose/compose-file/#volume-configuration-reference
The docker-compose.yml file might look something like this:
version: '2'
services:
ghost:
build:
context: ./ghost
ports:
- "80:80"
- "443:443"
volumes:
- "ftpsharevolume:/mnt/ftp"
depends_on:
- ftp
ftp:
image: someftpdockerimage
volumes:
- "ftpsharevolume:/srv/ftp"
ports:
- "21:21"
- "20:20"
volumes:
ftpsharevolume:
driver: local
来源:https://stackoverflow.com/questions/26556198/ftp-into-existing-docker-containers