NTDF
NTDF

Reputation: 31

Copy a file from host to a running docker container from within the container?

I have a running docker container with some service running inside it. Using that service, I want to pull a file from the host into the container.

Is it even possible to pull/copy a file into a container from a service running inside the container? What are my possibilities here? ftp? telnet? What are my options?

Thanks

Upvotes: 1

Views: 159

Answers (2)

meliora245
meliora245

Reputation: 53

Pass the host path as a parameter to your docker container, customize the docker image to read the file from the path(read above in parameter) and use the file as required. You could validate the same in docker entry point script.

Upvotes: 0

tgogos
tgogos

Reputation: 25122

I don't think you have many options. An idea is that if:

  • the host has a web server (or FTP server) up and running
  • and the file is located in the appropriate directory (so that it can be served)

maybe you can use wget or curl to get the file. Keep in mind that you might need credentials though...


IMHO, if what you are asking for is doable, it is a security hole.

Upvotes: 1

Related Questions