Search code examples
dockerdockerfilepdf-reactordocker-copy

How to reference embedded Docker resource files using file path URL


I have created a Docker image and embedded some static resource files within it, using the following command in the Dockerfile:

COPY resources /resources

I have a java web application running within the Docker container which requires access to these static files. File paths must be provided using a URL, E.g.:

file://c:/resources/myresourcefile.css

I am able to construct the URL programmatically but am unsure if embedded files can be referenced this way. Any guidance would be appreciated!

Note: I am specifically using the pdfreactor web service, and my Dockerfile is thus:

FROM realobjects/pdfreactor:9.1
EXPOSE 9423
COPY resources /resources

I am trying to set the "BaseURL" of the PDFreactor wrapper client to the root resource folder.


Solution

  • If it’s a Linux container, and the requestor is specifically your Java process running inside the container, then file:///resources will point at the directory you added (a subdirectory of the image root directory). If the URL is being served to something outside the container (like an HTML link or image reference) then a file: URL won’t be able to access files inside the container; you’d have to come up with something else to serve up the files and provide an HTTP URL to them.